diff --git a/presto-base-arrow-flight/src/test/java/com/facebook/plugin/arrow/TestArrowFlightNativeQueries.java b/presto-base-arrow-flight/src/test/java/com/facebook/plugin/arrow/TestArrowFlightNativeQueries.java index 4a7ec396867ab..21ee7f53ed78a 100644 --- a/presto-base-arrow-flight/src/test/java/com/facebook/plugin/arrow/TestArrowFlightNativeQueries.java +++ b/presto-base-arrow-flight/src/test/java/com/facebook/plugin/arrow/TestArrowFlightNativeQueries.java @@ -317,6 +317,12 @@ public void testSign() assertQuery("SELECT sign(shippriority) from orders"); } + @Test + public void testQueryWithColumnHandleOrdering() + { + assertQuery("SELECT * FROM nation WHERE (name <= 'B' OR 'G' <= name) AND (nationkey BETWEEN 1 AND 10)"); + } + public static Map getNativeWorkerSystemProperties() { return ImmutableMap.builder() diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/arrow_flight/presto_protocol_arrow_flight.h b/presto-native-execution/presto_cpp/presto_protocol/connector/arrow_flight/presto_protocol_arrow_flight.h index 2a9cb81d00b47..b78f064e2cb1c 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/connector/arrow_flight/presto_protocol_arrow_flight.h +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/arrow_flight/presto_protocol_arrow_flight.h @@ -38,15 +38,38 @@ void to_json(json& j, const ArrowTransactionHandle& p); void from_json(const json& j, ArrowTransactionHandle& p); } // namespace facebook::presto::protocol::arrow_flight +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ArrowColumnHandle is special since it needs an implementation of +// operator<(). + namespace facebook::presto::protocol::arrow_flight { struct ArrowColumnHandle : public ColumnHandle { String columnName = {}; Type columnType = {}; ArrowColumnHandle() noexcept; + + bool operator<(const ColumnHandle& o) const override { + return columnName < dynamic_cast(o).columnName; + } }; + void to_json(json& j, const ArrowColumnHandle& p); void from_json(const json& j, ArrowColumnHandle& p); + } // namespace facebook::presto::protocol::arrow_flight namespace facebook::presto::protocol::arrow_flight { struct ArrowSplit : public ConnectorSplit { diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/arrow_flight/special/ArrowColumnHandle.hpp.inc b/presto-native-execution/presto_cpp/presto_protocol/connector/arrow_flight/special/ArrowColumnHandle.hpp.inc new file mode 100644 index 0000000000000..0997d01ca896c --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/arrow_flight/special/ArrowColumnHandle.hpp.inc @@ -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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ArrowColumnHandle is special since it needs an implementation of +// operator<(). + +namespace facebook::presto::protocol::arrow_flight { +struct ArrowColumnHandle : public ColumnHandle { + String columnName = {}; + Type columnType = {}; + + ArrowColumnHandle() noexcept; + + bool operator<(const ColumnHandle& o) const override { + return columnName < dynamic_cast(o).columnName; + } +}; + +void to_json(json& j, const ArrowColumnHandle& p); +void from_json(const json& j, ArrowColumnHandle& p); + +} // namespace facebook::presto::protocol::arrow_flight diff --git a/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol-json-hpp.mustache b/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol-json-hpp.mustache index d3900d7d98f14..abba94d67115c 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol-json-hpp.mustache +++ b/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol-json-hpp.mustache @@ -246,7 +246,7 @@ namespace facebook::presto::protocol { {{/fields}} {{#comparable}} virtual bool operator<(const {{&class_name}}& /* o */) const { - throw std::runtime_error("missing operator<() in {class_name} subclass"); + throw std::runtime_error("missing operator<() in {{class_name}} subclass"); } {{/comparable}} }; diff --git a/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.h b/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.h index a08e2d7eb5914..8610697add0a8 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.h +++ b/presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.h @@ -335,7 +335,7 @@ void from_json(const json& j, std::shared_ptr& p); namespace facebook::presto::protocol { struct ColumnHandle : public JsonEncodedSubclass { virtual bool operator<(const ColumnHandle& /* o */) const { - throw std::runtime_error("missing operator<() in {class_name} subclass"); + throw std::runtime_error("missing operator<() in ColumnHandle subclass"); } }; void to_json(json& j, const std::shared_ptr& p);