use of io.prestosql.sql.tree.Comment in project hetu-core by openlookeng.
the class HiveAstBuilder method visitCommentTable.
@Override
public Node visitCommentTable(HiveSqlParser.CommentTableContext context) {
Optional<String> comment = Optional.empty();
List<Property> tableProperties = visit(context.properties().property(), Property.class);
for (int i = 0; i < tableProperties.size(); i++) {
Property property = tableProperties.get(i);
if (property.getName().getValue().equalsIgnoreCase("comment")) {
comment = Optional.of(unquote(property.getValue().toString()));
} else {
addDiff(DiffType.UNSUPPORTED, property.getName().getValue(), format("[SET TBLPROPERTIES: %s] is not supported", property.getName().getValue()));
throw unsupportedError(ErrorType.UNSUPPORTED_STATEMENT, format("Unsupported attribute: %s", property.getName().getValue()), context.properties());
}
}
addDiff(DiffType.MODIFIED, context.ALTER().getText(), "COMMENT ON TABLE", "[ALTER TABLE] is formatted to [COMMENT ON TABLE]");
addDiff(DiffType.MODIFIED, context.TABLE().getText(), null);
return new Comment(getLocation(context), Comment.Type.TABLE, getQualifiedName(context.qualifiedName()), comment);
}
use of io.prestosql.sql.tree.Comment in project hetu-core by openlookeng.
the class TestSqlParser method testCommentTable.
@Test
public void testCommentTable() {
assertStatement("COMMENT ON TABLE a IS 'test'", new Comment(Comment.Type.TABLE, QualifiedName.of("a"), Optional.of("test")));
assertStatement("COMMENT ON TABLE a IS ''", new Comment(Comment.Type.TABLE, QualifiedName.of("a"), Optional.of("")));
assertStatement("COMMENT ON TABLE a IS NULL", new Comment(Comment.Type.TABLE, QualifiedName.of("a"), Optional.empty()));
}