Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions core/trino-parser/src/main/java/io/trino/sql/SqlFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ protected Void visitSingleColumn(SingleColumn node, Integer indent)
}

@Override
protected Void visitAllColumns(AllColumns node, Integer context)
protected Void visitAllColumns(AllColumns node, Integer indent)
{
node.getTarget().ifPresent(value -> builder
.append(formatExpression(value))
Expand Down Expand Up @@ -811,7 +811,7 @@ protected Void visitCreateView(CreateView node, Integer indent)
}

@Override
protected Void visitRenameView(RenameView node, Integer context)
protected Void visitRenameView(RenameView node, Integer indent)
{
builder.append("ALTER VIEW ")
.append(node.getSource())
Expand All @@ -822,7 +822,7 @@ protected Void visitRenameView(RenameView node, Integer context)
}

@Override
protected Void visitRenameMaterializedView(RenameMaterializedView node, Integer context)
protected Void visitRenameMaterializedView(RenameMaterializedView node, Integer indent)
{
builder.append("ALTER MATERIALIZED VIEW ");
if (node.isExists()) {
Expand All @@ -836,7 +836,7 @@ protected Void visitRenameMaterializedView(RenameMaterializedView node, Integer
}

@Override
protected Void visitSetViewAuthorization(SetViewAuthorization node, Integer context)
protected Void visitSetViewAuthorization(SetViewAuthorization node, Integer indent)
{
builder.append("ALTER VIEW ")
.append(formatName(node.getSource()))
Expand Down Expand Up @@ -872,7 +872,7 @@ protected Void visitCreateMaterializedView(CreateMaterializedView node, Integer
}

@Override
protected Void visitRefreshMaterializedView(RefreshMaterializedView node, Integer context)
protected Void visitRefreshMaterializedView(RefreshMaterializedView node, Integer indent)
{
builder.append("REFRESH MATERIALIZED VIEW ");
builder.append(formatName(node.getName()));
Expand All @@ -881,7 +881,7 @@ protected Void visitRefreshMaterializedView(RefreshMaterializedView node, Intege
}

@Override
protected Void visitDropMaterializedView(DropMaterializedView node, Integer context)
protected Void visitDropMaterializedView(DropMaterializedView node, Integer indent)
{
builder.append("DROP MATERIALIZED VIEW ");
if (node.isExists()) {
Expand All @@ -892,7 +892,7 @@ protected Void visitDropMaterializedView(DropMaterializedView node, Integer cont
}

@Override
protected Void visitDropView(DropView node, Integer context)
protected Void visitDropView(DropView node, Integer indent)
{
builder.append("DROP VIEW ");
if (node.isExists()) {
Expand Down Expand Up @@ -950,7 +950,7 @@ protected Void visitExplainAnalyze(ExplainAnalyze node, Integer indent)
}

@Override
protected Void visitShowCatalogs(ShowCatalogs node, Integer context)
protected Void visitShowCatalogs(ShowCatalogs node, Integer indent)
{
builder.append("SHOW CATALOGS");

Expand All @@ -966,7 +966,7 @@ protected Void visitShowCatalogs(ShowCatalogs node, Integer context)
}

@Override
protected Void visitShowSchemas(ShowSchemas node, Integer context)
protected Void visitShowSchemas(ShowSchemas node, Integer indent)
{
builder.append("SHOW SCHEMAS");

Expand All @@ -987,7 +987,7 @@ protected Void visitShowSchemas(ShowSchemas node, Integer context)
}

@Override
protected Void visitShowTables(ShowTables node, Integer context)
protected Void visitShowTables(ShowTables node, Integer indent)
{
builder.append("SHOW TABLES");

Expand All @@ -1007,7 +1007,7 @@ protected Void visitShowTables(ShowTables node, Integer context)
}

@Override
protected Void visitShowCreate(ShowCreate node, Integer context)
protected Void visitShowCreate(ShowCreate node, Integer indent)
{
if (node.getType() == ShowCreate.Type.TABLE) {
builder.append("SHOW CREATE TABLE ")
Expand All @@ -1025,7 +1025,7 @@ else if (node.getType() == ShowCreate.Type.MATERIALIZED_VIEW) {
}

@Override
protected Void visitShowColumns(ShowColumns node, Integer context)
protected Void visitShowColumns(ShowColumns node, Integer indent)
{
builder.append("SHOW COLUMNS FROM ")
.append(formatName(node.getTable()));
Expand All @@ -1042,7 +1042,7 @@ protected Void visitShowColumns(ShowColumns node, Integer context)
}

@Override
protected Void visitShowStats(ShowStats node, Integer context)
protected Void visitShowStats(ShowStats node, Integer indent)
{
builder.append("SHOW STATS FOR ");
process(node.getRelation(), 0);
Expand All @@ -1051,7 +1051,7 @@ protected Void visitShowStats(ShowStats node, Integer context)
}

@Override
protected Void visitShowFunctions(ShowFunctions node, Integer context)
protected Void visitShowFunctions(ShowFunctions node, Integer indent)
{
builder.append("SHOW FUNCTIONS");

Expand All @@ -1067,7 +1067,7 @@ protected Void visitShowFunctions(ShowFunctions node, Integer context)
}

@Override
protected Void visitShowSession(ShowSession node, Integer context)
protected Void visitShowSession(ShowSession node, Integer indent)
{
builder.append("SHOW SESSION");

Expand All @@ -1083,7 +1083,7 @@ protected Void visitShowSession(ShowSession node, Integer context)
}

@Override
protected Void visitDelete(Delete node, Integer context)
protected Void visitDelete(Delete node, Integer indent)
{
builder.append("DELETE FROM ")
.append(formatName(node.getTable().getName()));
Expand All @@ -1097,7 +1097,7 @@ protected Void visitDelete(Delete node, Integer context)
}

@Override
protected Void visitCreateSchema(CreateSchema node, Integer context)
protected Void visitCreateSchema(CreateSchema node, Integer indent)
{
builder.append("CREATE SCHEMA ");
if (node.isNotExists()) {
Expand All @@ -1114,7 +1114,7 @@ protected Void visitCreateSchema(CreateSchema node, Integer context)
}

@Override
protected Void visitDropSchema(DropSchema node, Integer context)
protected Void visitDropSchema(DropSchema node, Integer indent)
{
builder.append("DROP SCHEMA ");
if (node.isExists()) {
Expand All @@ -1128,7 +1128,7 @@ protected Void visitDropSchema(DropSchema node, Integer context)
}

@Override
protected Void visitRenameSchema(RenameSchema node, Integer context)
protected Void visitRenameSchema(RenameSchema node, Integer indent)
{
builder.append("ALTER SCHEMA ")
.append(formatName(node.getSource()))
Expand All @@ -1139,7 +1139,7 @@ protected Void visitRenameSchema(RenameSchema node, Integer context)
}

@Override
protected Void visitSetSchemaAuthorization(SetSchemaAuthorization node, Integer context)
protected Void visitSetSchemaAuthorization(SetSchemaAuthorization node, Integer indent)
{
builder.append("ALTER SCHEMA ")
.append(formatName(node.getSource()))
Expand Down Expand Up @@ -1297,7 +1297,7 @@ private static String formatPrincipal(PrincipalSpecification principal)
}

@Override
protected Void visitDropTable(DropTable node, Integer context)
protected Void visitDropTable(DropTable node, Integer indent)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkArgument? (and below)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Sequence of private methods fooled me. We are already past public interface.

{
builder.append("DROP TABLE ");
if (node.isExists()) {
Expand All @@ -1309,7 +1309,7 @@ protected Void visitDropTable(DropTable node, Integer context)
}

@Override
protected Void visitRenameTable(RenameTable node, Integer context)
protected Void visitRenameTable(RenameTable node, Integer indent)
{
builder.append("ALTER TABLE ");
if (node.isExists()) {
Expand All @@ -1323,7 +1323,7 @@ protected Void visitRenameTable(RenameTable node, Integer context)
}

@Override
protected Void visitComment(Comment node, Integer context)
protected Void visitComment(Comment node, Integer indent)
{
String comment = node.getComment().isPresent() ? formatStringLiteral(node.getComment().get()) : "NULL";

Expand All @@ -1346,7 +1346,7 @@ protected Void visitComment(Comment node, Integer context)
}

@Override
protected Void visitRenameColumn(RenameColumn node, Integer context)
protected Void visitRenameColumn(RenameColumn node, Integer indent)
{
builder.append("ALTER TABLE ");
if (node.isTableExists()) {
Expand All @@ -1365,7 +1365,7 @@ protected Void visitRenameColumn(RenameColumn node, Integer context)
}

@Override
protected Void visitDropColumn(DropColumn node, Integer context)
protected Void visitDropColumn(DropColumn node, Integer indent)
{
builder.append("ALTER TABLE ");
if (node.isTableExists()) {
Expand All @@ -1382,7 +1382,7 @@ protected Void visitDropColumn(DropColumn node, Integer context)
}

@Override
protected Void visitAnalyze(Analyze node, Integer context)
protected Void visitAnalyze(Analyze node, Integer indent)
{
builder.append("ANALYZE ")
.append(formatName(node.getTableName()));
Expand All @@ -1408,7 +1408,7 @@ protected Void visitAddColumn(AddColumn node, Integer indent)
}

@Override
protected Void visitSetTableAuthorization(SetTableAuthorization node, Integer context)
protected Void visitSetTableAuthorization(SetTableAuthorization node, Integer indent)
{
builder.append("ALTER TABLE ")
.append(formatName(node.getSource()))
Expand Down Expand Up @@ -1464,7 +1464,7 @@ protected Void visitUpdate(Update node, Integer indent)
}

@Override
public Void visitSetSession(SetSession node, Integer context)
public Void visitSetSession(SetSession node, Integer indent)
{
builder.append("SET SESSION ")
.append(node.getName())
Expand All @@ -1475,7 +1475,7 @@ public Void visitSetSession(SetSession node, Integer context)
}

@Override
public Void visitResetSession(ResetSession node, Integer context)
public Void visitResetSession(ResetSession node, Integer indent)
{
builder.append("RESET SESSION ")
.append(node.getName());
Expand Down Expand Up @@ -1555,28 +1555,28 @@ protected Void visitIsolationLevel(Isolation node, Integer indent)
}

@Override
protected Void visitTransactionAccessMode(TransactionAccessMode node, Integer context)
protected Void visitTransactionAccessMode(TransactionAccessMode node, Integer indent)
{
builder.append(node.isReadOnly() ? "READ ONLY" : "READ WRITE");
return null;
}

@Override
protected Void visitCommit(Commit node, Integer context)
protected Void visitCommit(Commit node, Integer indent)
{
builder.append("COMMIT");
return null;
}

@Override
protected Void visitRollback(Rollback node, Integer context)
protected Void visitRollback(Rollback node, Integer indent)
{
builder.append("ROLLBACK");
return null;
}

@Override
protected Void visitCreateRole(CreateRole node, Integer context)
protected Void visitCreateRole(CreateRole node, Integer indent)
{
builder.append("CREATE ROLE ").append(node.getName());
if (node.getGrantor().isPresent()) {
Expand All @@ -1590,7 +1590,7 @@ protected Void visitCreateRole(CreateRole node, Integer context)
}

@Override
protected Void visitDropRole(DropRole node, Integer context)
protected Void visitDropRole(DropRole node, Integer indent)
{
builder.append("DROP ROLE ").append(node.getName());
if (node.getCatalog().isPresent()) {
Expand All @@ -1601,7 +1601,7 @@ protected Void visitDropRole(DropRole node, Integer context)
}

@Override
protected Void visitGrantRoles(GrantRoles node, Integer context)
protected Void visitGrantRoles(GrantRoles node, Integer indent)
{
builder.append("GRANT ");
builder.append(node.getRoles().stream()
Expand All @@ -1625,7 +1625,7 @@ protected Void visitGrantRoles(GrantRoles node, Integer context)
}

@Override
protected Void visitRevokeRoles(RevokeRoles node, Integer context)
protected Void visitRevokeRoles(RevokeRoles node, Integer indent)
{
builder.append("REVOKE ");
if (node.isAdminOption()) {
Expand All @@ -1649,7 +1649,7 @@ protected Void visitRevokeRoles(RevokeRoles node, Integer context)
}

@Override
protected Void visitSetRole(SetRole node, Integer context)
protected Void visitSetRole(SetRole node, Integer indent)
{
builder.append("SET ROLE ");
SetRole.Type type = node.getType();
Expand Down Expand Up @@ -1746,7 +1746,7 @@ public Void visitShowGrants(ShowGrants node, Integer indent)
}

@Override
protected Void visitShowRoles(ShowRoles node, Integer context)
protected Void visitShowRoles(ShowRoles node, Integer indent)
{
builder.append("SHOW ");
if (node.isCurrent()) {
Expand All @@ -1763,7 +1763,7 @@ protected Void visitShowRoles(ShowRoles node, Integer context)
}

@Override
protected Void visitShowRoleGrants(ShowRoleGrants node, Integer context)
protected Void visitShowRoleGrants(ShowRoleGrants node, Integer indent)
{
builder.append("SHOW ROLE GRANTS");

Expand Down