| /* | |
| * 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. | |
| */ | |
| #include "bolt/common/base/tests/GTestUtils.h" | |
| #include "substrait/BoltToSubstraitType.h" | |
| #include "substrait/SubstraitParser.h" | |
| #include "substrait/TypeUtils.h" | |
| using namespace bytedance::bolt; | |
| namespace gluten { | |
| class BoltToSubstraitTypeTest : public ::testing::Test { | |
| protected: | |
| void testTypeConversion(const TypePtr& type) { | |
| SCOPED_TRACE(type->toString()); | |
| google::protobuf::Arena arena; | |
| auto substraitType = typeConvertor_->toSubstraitType(arena, type); | |
| auto sameType = SubstraitParser::parseType(substraitType); | |
| ASSERT_TRUE(sameType->kindEquals(type)) | |
| << "Expected: " << type->toString() << ", but got: " << sameType->toString(); | |
| } | |
| std::shared_ptr<BoltToSubstraitTypeConvertor> typeConvertor_; | |
| }; | |
| TEST_F(BoltToSubstraitTypeTest, basic) { | |
| testTypeConversion(BOOLEAN()); | |
| testTypeConversion(TINYINT()); | |
| testTypeConversion(SMALLINT()); | |
| testTypeConversion(INTEGER()); | |
| testTypeConversion(BIGINT()); | |
| testTypeConversion(REAL()); | |
| testTypeConversion(DOUBLE()); | |
| testTypeConversion(VARCHAR()); | |
| testTypeConversion(VARBINARY()); | |
| testTypeConversion(ARRAY(BIGINT())); | |
| testTypeConversion(MAP(BIGINT(), DOUBLE())); | |
| testTypeConversion(ROW({"a", "b", "c"}, {BIGINT(), BOOLEAN(), VARCHAR()})); | |
| testTypeConversion(ROW({"a", "b", "c"}, {BIGINT(), ROW({"x", "y"}, {BOOLEAN(), VARCHAR()}), REAL()})); | |
| testTypeConversion(ROW({}, {})); | |
| } | |
| } // namespace gluten |