Skip to content

Commit

Permalink
Display proper view name for show create queries
Browse files Browse the repository at this point in the history
When the query has a fully qualified view name for show create, generated result displays the name in a wrong order. This patch ensures that view name is shown in proper order.
  • Loading branch information
Praveen2112 authored and martint committed Mar 11, 2019
1 parent 663583e commit 21583ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Lists;
import com.google.common.primitives.Primitives;
import io.prestosql.Session;
import io.prestosql.connector.ConnectorId;
Expand Down Expand Up @@ -430,7 +431,7 @@ protected Node visitShowCreate(ShowCreate node, Void context)
}

Query query = parseView(viewDefinition.get().getOriginalSql(), objectName, node);
List<Identifier> parts = node.getName().getOriginalParts();
List<Identifier> parts = Lists.reverse(node.getName().getOriginalParts());
Identifier tableName = parts.get(0);
Identifier schemaName = (parts.size() > 1) ? parts.get(1) : new Identifier(objectName.getSchemaName());
Identifier catalogName = (parts.size() > 2) ? parts.get(2) : new Identifier(objectName.getCatalogName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ public void testViewMetadata()

assertEquals(getOnlyElement(actual.getOnlyColumnAsSet()), expectedSql);

actual = computeActual(format("SHOW CREATE VIEW %s.%s.meta_test_view", getSession().getCatalog().get(), getSession().getSchema().get()));

assertEquals(getOnlyElement(actual.getOnlyColumnAsSet()), expectedSql);

assertUpdate("DROP VIEW meta_test_view");
}

Expand Down

0 comments on commit 21583ac

Please sign in to comment.