Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Feb 12, 2024
1 parent ec8f612 commit 7f95ca8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions velox/vector/arrow/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ const char* exportArrowFormatStr(
return "u"; // utf-8 string
case TypeKind::VARBINARY:
return "z"; // binary
case TypeKind::UNKNOWN:
return "n"; // NullType

case TypeKind::TIMESTAMP:
return "ttn"; // time64 [nanoseconds]
Expand All @@ -259,8 +261,6 @@ const char* exportArrowFormatStr(
return "+m"; // map
case TypeKind::ROW:
return "+s"; // struct
case TypeKind::UNKNOWN:
return "n";

default:
VELOX_NYI("Unable to map type '{}' to ArrowSchema.", type->kind());
Expand Down
19 changes: 4 additions & 15 deletions velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,25 +238,14 @@ TEST_F(ArrowBridgeSchemaExportTest, constant) {
testConstant(DOUBLE(), "g");
testConstant(VARCHAR(), "u");
testConstant(DATE(), "tdD");
testConstant(UNKNOWN(), "n");

testConstant(ARRAY(INTEGER()), "+l");
testConstant(ARRAY(UNKNOWN()), "+l");
testConstant(MAP(BOOLEAN(), REAL()), "+m");
testConstant(MAP(UNKNOWN(), REAL()), "+m");
testConstant(ROW({TIMESTAMP(), DOUBLE()}), "+s");
}

TEST_F(ArrowBridgeSchemaExportTest, unsupported) {
GTEST_SKIP() << "Skipping it, cause unknown type supported";
// Try some combination of unsupported types to ensure there's no crash or
// memory leak in failure scenarios.
EXPECT_THROW(testScalarType(UNKNOWN(), ""), VeloxException);

EXPECT_THROW(testScalarType(ARRAY(UNKNOWN()), ""), VeloxException);
EXPECT_THROW(testScalarType(MAP(UNKNOWN(), INTEGER()), ""), VeloxException);
EXPECT_THROW(testScalarType(MAP(BIGINT(), UNKNOWN()), ""), VeloxException);

EXPECT_THROW(testScalarType(ROW({BIGINT(), UNKNOWN()}), ""), VeloxException);
EXPECT_THROW(
testScalarType(ROW({BIGINT(), REAL(), UNKNOWN()}), ""), VeloxException);
testConstant(ROW({UNKNOWN(), UNKNOWN()}), "+s");
}

class ArrowBridgeSchemaImportTest : public ArrowBridgeSchemaExportTest {
Expand Down

0 comments on commit 7f95ca8

Please sign in to comment.