Extend HiveTypeParser to support Presto types #7502
Replies: 5 comments 4 replies
-
HiveTypeParser is a legacy code and we shouldn't be using it. Tests can create types more easily using macros: ROW, ARRAY, MAP, etc. |
Beta Was this translation helpful? Give feedback.
-
There is also type parsing logic in velox/expression/FunctionSignature.cpp
|
Beta Was this translation helpful? Give feedback.
-
@mbasmanova @majetideepak I used to want to reuse this method and add an API to transform the namespace {
TypePtr toVeloxType(const TypeSignature& typeSignature) {
if (typeSignature.baseName() == "bigint") {
return BIGINT();
} else if (typeSignature.baseName() == "double") {
return DOUBLE();
} else if (typeSignature.baseName() == "map") {
auto keyType = toVeloxType(typeSignature.parameters().front());
auto valType = toVeloxType(typeSignature.parameters().back());
return MAP(keyType, valType);
} else if (typeSignature.baseName() == "array") {
auto elementType = toVeloxType(typeSignature.parameters().front());
return ARRAY(elementType);
} else { // row
std::vector<TypePtr> elementTypes;
for (const auto& typeName : typeSignature.parameters()) {
elementTypes.emplace_back(toVeloxType(typeName));
}
return ROW(std::move(elementTypes));
}
}
} // namespace
TEST(ParseTypeSignatureTest, debug) {
ASSERT_NE(INTEGER(), toVeloxType(parseTypeSignature("bigint")));
ASSERT_EQ(BIGINT(), toVeloxType(parseTypeSignature("bigint")));
ASSERT_EQ(DOUBLE(), toVeloxType(parseTypeSignature("double")));
ASSERT_TRUE(MAP(BIGINT(), DOUBLE())->equivalent(
*toVeloxType(parseTypeSignature("map(bigint, double)"))));
ASSERT_TRUE(MAP(BIGINT(), ARRAY(DOUBLE()))->equivalent(
*toVeloxType(parseTypeSignature("map(bigint, array(double))"))));
ASSERT_TRUE(ROW({BIGINT(), MAP(BIGINT(), ARRAY(DOUBLE()))})->equivalent(
*toVeloxType(parseTypeSignature("row(bigint,map(bigint, array(double)))"))));
}
|
Beta Was this translation helpful? Give feedback.
-
@duanmeng Sounds like we can use this to get unblocked. It would be nice to continue making progress on brining PrestoQueryRunner to Velox and starting to run Fuzzer using that. |
Beta Was this translation helpful? Give feedback.
-
This discussion is now resolved with #7568 |
Beta Was this translation helpful? Give feedback.
-
We have a HiveTypeParser in Velox to parse Hive Types. I see that this is mainly used in testing (DWRF mostly) and in RemoteFunctionService.
Why do we use Hive Types style for testing? Why not Presto style?
We use antlr to parse Presto Type in Prestissimo. There is now a need to move the Presto Type parser to Velox to support PrestoQueryRunner in Velox.
We can easily extend the HiveTypeParser to parse Presto Types.
The missing pieces are
<
in Hive and(
in Presto. We can make this configurable.functiontype
. Should be straightforward to add this.timestamp with timezone
.We can remove the dependency on antlr in Prestissimo with this support.
Beta Was this translation helpful? Give feedback.
All reactions