Search in sources :

Example 1 with Comment

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);
}
Also used : Comment(io.prestosql.sql.tree.Comment) Property(io.prestosql.sql.tree.Property)

Example 2 with 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()));
}
Also used : Comment(io.prestosql.sql.tree.Comment) Test(org.testng.annotations.Test)

Aggregations

Comment (io.prestosql.sql.tree.Comment)2 Property (io.prestosql.sql.tree.Property)1 Test (org.testng.annotations.Test)1