Search in sources :

Example 1 with ShowColumns

use of io.prestosql.sql.tree.ShowColumns in project hetu-core by openlookeng.

the class HiveAstBuilder method visitDescribeTable.

@Override
public Node visitDescribeTable(HiveSqlParser.DescribeTableContext context) {
    if (context.EXTENDED() != null) {
        addDiff(DiffType.UNSUPPORTED, context.EXTENDED().getText(), "[EXTENDED] is not supported");
        throw unsupportedError(ErrorType.UNSUPPORTED_STATEMENT, "Unsupported attribute: EXTENDED", context);
    }
    if (context.FORMATTED() != null) {
        addDiff(DiffType.UNSUPPORTED, context.FORMATTED().getText(), "[FORMATTED] is not supported");
        throw unsupportedError(ErrorType.UNSUPPORTED_STATEMENT, "Unsupported attribute: FORMATTED", context);
    }
    if (context.describeTableOption() != null) {
        addDiff(DiffType.UNSUPPORTED, context.describeTableOption().getText(), "[DESCRIBE TABLE OPTION] is not supported");
        throw unsupportedError(ErrorType.UNSUPPORTED_STATEMENT, "Unsupported Describe statement", context.describeTableOption());
    }
    String source = context.DESCRIBE() != null ? context.DESCRIBE().getText() : context.DESC().getText();
    addDiff(DiffType.MODIFIED, source, "SHOW COLUMNS FROM", format("keyword: [%s] is updated to [SHOW COLUMNS FROM]", source.toUpperCase(ENGLISH)));
    QualifiedName qualifiedName = QualifiedName.of(visit(context.describeName().identifier(), Identifier.class));
    return new ShowColumns(getLocation(context), qualifiedName);
}
Also used : Identifier(io.prestosql.sql.tree.Identifier) QualifiedName(io.prestosql.sql.tree.QualifiedName) ShowColumns(io.prestosql.sql.tree.ShowColumns)

Example 2 with ShowColumns

use of io.prestosql.sql.tree.ShowColumns in project hetu-core by openlookeng.

the class TestSqlParser method testShowColumns.

@Test
public void testShowColumns() {
    assertStatement("SHOW COLUMNS FROM a", new ShowColumns(QualifiedName.of("a")));
    assertStatement("SHOW COLUMNS FROM a.b", new ShowColumns(QualifiedName.of("a", "b")));
    assertStatement("SHOW COLUMNS FROM \"awesome table\"", new ShowColumns(QualifiedName.of("awesome table")));
    assertStatement("SHOW COLUMNS FROM \"awesome schema\".\"awesome table\"", new ShowColumns(QualifiedName.of("awesome schema", "awesome table")));
}
Also used : ShowColumns(io.prestosql.sql.tree.ShowColumns) Test(org.testng.annotations.Test)

Aggregations

ShowColumns (io.prestosql.sql.tree.ShowColumns)2 Identifier (io.prestosql.sql.tree.Identifier)1 QualifiedName (io.prestosql.sql.tree.QualifiedName)1 Test (org.testng.annotations.Test)1