* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.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.
*/
#pragma once
#include "velox/core/PlanNode.h"
#include "SubstraitExtensionCollector.h"
#include "VeloxToSubstraitType.h"
#include "substrait/algebra.pb.h"
#include "velox/vector/ConstantVector.h"
namespace gluten {
class VeloxToSubstraitExprConvertor {
public:
explicit VeloxToSubstraitExprConvertor(const SubstraitExtensionCollectorPtr& extensionCollector)
: extensionCollector_(extensionCollector) {}
const ::substrait::Expression&
toSubstraitExpr(google::protobuf::Arena& arena, const core::TypedExprPtr& expr, const RowTypePtr& inputType);
const ::substrait::Expression_Literal& toSubstraitExpr(
google::protobuf::Arena& arena,
const std::shared_ptr<const core::ConstantTypedExpr>& constExpr,
::substrait::Expression_Literal_Struct* litValue = nullptr);
const ::substrait::Expression_FieldReference& toSubstraitExpr(
google::protobuf::Arena& arena,
const std::shared_ptr<const core::FieldAccessTypedExpr>& fieldExpr,
const RowTypePtr& inputType);
const ::substrait::Expression_FieldReference& toSubstraitExpr(
google::protobuf::Arena& arena,
const std::shared_ptr<const core::DereferenceTypedExpr>& derefExpr,
const RowTypePtr& inputType);
const ::substrait::Expression_Literal& toSubstraitLiteral(
google::protobuf::Arena& arena,
const velox::VectorPtr& vectorValue,
::substrait::Expression_Literal_Struct* litValue);
private:
const ::substrait::Expression_Cast& toSubstraitExpr(
google::protobuf::Arena& arena,
const std::shared_ptr<const core::CastTypedExpr>& castExpr,
const RowTypePtr& inputType);
const ::substrait::Expression& toSubstraitExpr(
google::protobuf::Arena& arena,
const std::shared_ptr<const core::CallTypedExpr>& callTypeExpr,
const RowTypePtr& inputType);
const ::substrait::Expression_Literal& toSubstraitLiteral(
google::protobuf::Arena& arena,
const velox::variant& variantValue);
const ::substrait::Expression_Literal_List&
toSubstraitLiteralList(google::protobuf::Arena& arena, const ArrayVector* arrayVector, vector_size_t row);
const ::substrait::Type_List& toSubstraitLiteralEmptyList(google::protobuf::Arena& arena, const velox::TypePtr& type);
const ::substrait::Expression_Literal& toSubstraitLiteralComplex(
google::protobuf::Arena& arena,
const std::shared_ptr<ConstantVector<ComplexType>>& constantVector);
VeloxToSubstraitTypeConvertorPtr typeConvertor_;
SubstraitExtensionCollectorPtr extensionCollector_;
};
}