Skip to content

Commit

Permalink
improve error msg of HiveTypeSerializer (#11118)
Browse files Browse the repository at this point in the history
Summary:
so it's clear why it's failing

Pull Request resolved: #11118

Reviewed By: xiaoxmeng

Differential Revision: D63554207

Pulled By: kunigami

fbshipit-source-id: 47716785b5128721540d66dee639d3c1d655b7b8
  • Loading branch information
kunigami authored and facebook-github-bot committed Oct 4, 2024
1 parent 6f40034 commit fef4915
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion velox/type/fbhive/HiveTypeSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::string HiveTypeSerializer::visit(const Type& type) const {
case TypeKind::ROW:
return "struct<" + visitChildren(type.asRow()) + ">";
default:
throw std::logic_error("unknown batch type");
VELOX_UNSUPPORTED("unsupported type: " + type.toString());
}
}

Expand Down
15 changes: 15 additions & 0 deletions velox/type/fbhive/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,18 @@ target_link_libraries(
GTest::gtest
GTest::gtest_main
GTest::gmock)

add_executable(velox_type_serializer_fbhive_test HiveTypeSerializerTests.cpp)

add_test(
NAME velox_type_serializer_fbhive_test
COMMAND velox_type_serializer_fbhive_test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(
velox_type_serializer_fbhive_test
velox_type_fbhive
velox_type
GTest::gtest
GTest::gtest_main
GTest::gmock)
41 changes: 41 additions & 0 deletions velox/type/fbhive/tests/HiveTypeSerializerTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.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 <memory>
#include <stdexcept>

#include "gtest/gtest-message.h"
#include "gtest/gtest-test-part.h"
#include "gtest/gtest.h"
#include "velox/common/base/tests/GTestUtils.h"
#include "velox/type/fbhive/HiveTypeSerializer.h"

using facebook::velox::TypeKind;

namespace facebook::velox::type::fbhive {

TEST(HiveTypeSerializer, primitive) {
std::shared_ptr<const velox::Type> type = velox::BIGINT();
auto result = HiveTypeSerializer::serialize(type);
EXPECT_EQ(result, "bigint");
}

TEST(HiveTypeSerializer, opaque) {
std::shared_ptr<const velox::Type> type = velox::OPAQUE<bool>();
VELOX_ASSERT_THROW(
HiveTypeSerializer::serialize(type), "unsupported type: OPAQUE<bool>");
}
} // namespace facebook::velox::type::fbhive

0 comments on commit fef4915

Please sign in to comment.