Skip to content

Commit

Permalink
[FLINK-22341][hive] Fix describe table for hive dialect
Browse files Browse the repository at this point in the history
This closes apache#15660
  • Loading branch information
lirui-apache committed Apr 22, 2021
1 parent 04ce600 commit 0270244
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ private Serializable analyzeDescribeTable(HiveParserASTNode ast) throws Semantic
if (partSpec != null) {
handleUnsupportedOperation("DESCRIBE PARTITION is not supported");
}
if (colPath != null) {
if (!colPath.equals(tableName)) {
handleUnsupportedOperation("DESCRIBE COLUMNS is not supported");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
import org.apache.flink.table.api.internal.TableEnvironmentInternal;
import org.apache.flink.table.catalog.CatalogPartitionSpec;
import org.apache.flink.table.catalog.CatalogTable;
import org.apache.flink.table.catalog.ObjectIdentifier;
import org.apache.flink.table.catalog.ObjectPath;
import org.apache.flink.table.catalog.hive.HiveCatalog;
import org.apache.flink.table.catalog.hive.HiveTestUtils;
import org.apache.flink.table.delegation.Parser;
import org.apache.flink.table.operations.DescribeTableOperation;
import org.apache.flink.table.operations.command.ClearOperation;
import org.apache.flink.table.operations.command.HelpOperation;
import org.apache.flink.table.operations.command.QuitOperation;
Expand Down Expand Up @@ -255,6 +257,27 @@ public void testCreateTable() throws Exception {
tableEnv.executeSql("create table if not exists tbl5 (m map<bigint,string>)");
hiveTable = hiveCatalog.getHiveTable(new ObjectPath("default", "tbl5"));
assertEquals(createdTimeForTableExists, hiveTable.getCreateTime());

// test describe table
Parser parser = ((TableEnvironmentInternal) tableEnv).getParser();
DescribeTableOperation operation =
(DescribeTableOperation) parser.parse("desc tbl1").get(0);
assertFalse(operation.isExtended());
assertEquals(
ObjectIdentifier.of(hiveCatalog.getName(), "default", "tbl1"),
operation.getSqlIdentifier());

operation = (DescribeTableOperation) parser.parse("describe default.tbl2").get(0);
assertFalse(operation.isExtended());
assertEquals(
ObjectIdentifier.of(hiveCatalog.getName(), "default", "tbl2"),
operation.getSqlIdentifier());

operation = (DescribeTableOperation) parser.parse("describe extended tbl3").get(0);
assertTrue(operation.isExtended());
assertEquals(
ObjectIdentifier.of(hiveCatalog.getName(), "default", "tbl3"),
operation.getSqlIdentifier());
}

@Test
Expand Down

0 comments on commit 0270244

Please sign in to comment.