@Override protected RelationType visitShowColumns(ShowColumns showColumns, AnalysisContext context) { QualifiedObjectName tableName = createQualifiedObjectName(session, showColumns, showColumns.getTable()); if (!metadata.getView(session, tableName).isPresent() && !metadata.getTableHandle(session, tableName).isPresent()) { throw new SemanticException(MISSING_TABLE, showColumns, "Table '%s' does not exist", tableName); } Query query = simpleQuery( selectList( aliasedName("column_name", "Column"), aliasedName("data_type", "Type"), aliasedNullToEmpty("comment", "Comment")), from(tableName.getCatalogName(), TABLE_COLUMNS), logicalAnd( equal(nameReference("table_schema"), new StringLiteral(tableName.getSchemaName())), equal(nameReference("table_name"), new StringLiteral(tableName.getObjectName()))), ordering(ascending("ordinal_position"))); return process(query, context); }
@Override protected Void visitShowColumns(ShowColumns node, Integer context) { builder.append("SHOW COLUMNS FROM ") .append(node.getTable()); return null; }
@Override public Node visitShowColumns(SqlBaseParser.ShowColumnsContext context) { return new ShowColumns(getLocation(context), getQualifiedName(context.qualifiedName())); }