[
https://issues.apache.org/jira/browse/TAJO-1675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14709057#comment-14709057
]
ASF GitHub Bot commented on TAJO-1675:
--------------------------------------
Github user jihoonson commented on a diff in the pull request:
https://github.com/apache/tajo/pull/653#discussion_r37736825
--- Diff:
tajo-core-tests/src/test/java/org/apache/tajo/master/TestNonForwardQueryResultSystemScanner.java
---
@@ -38,4 +51,89 @@ public void testGetNextRowsForTable() throws Exception {
public void testGetClusterDetails() throws Exception {
assertQueryStr("SELECT TYPE FROM INFORMATION_SCHEMA.CLUSTER");
}
+
+ @Test
+ public final void testGetInformationSchema() throws Exception {
+ executeDDL("create_partitioned_table.sql", null);
+
+ String simpleTableName = "information_schema_test_table";
+ String tableName = CatalogUtil.buildFQName(getCurrentDatabase(),
simpleTableName);
+ assertTrue(catalog.existsTable(tableName));
+
+ TableDesc retrieved = catalog.getTableDesc(tableName);
+
+ executeDDL("alter_table_add_partition1.sql", null);
+ executeDDL("alter_table_add_partition2.sql", null);
+
+ List<CatalogProtos.DatabaseProto> allDatabases =
catalog.getAllDatabases();
+ int dbId = -1;
+ for (CatalogProtos.DatabaseProto database : allDatabases) {
+ if (database.getName().equals(getCurrentDatabase())) {
+ dbId = database.getId();
+ }
+ }
+ assertNotEquals(dbId, -1);
+
+ int tableId = -1;
+ List<CatalogProtos.TableDescriptorProto> allTables =
catalog.getAllTables();
+ for(CatalogProtos.TableDescriptorProto table : allTables) {
+ if (table.getDbId() == dbId &&
table.getName().equals(simpleTableName)) {
+ tableId = table.getTid();
+ }
+ }
+ assertNotEquals(tableId, -1);
+
+ List<CatalogProtos.PartitionDescProto> allPartitions =
catalog.getAllPartitions();
+ List<CatalogProtos.PartitionDescProto> resultPartitions =
TUtil.newList();
+
+ int partitionId = 0;
+ for (CatalogProtos.PartitionDescProto partition : allPartitions) {
+ if (partition.getTid() == tableId
+ && partition.getPartitionName().equals("col3=1/col4=2")
+ && partition.getPath().equals(retrieved.getUri().toString() +
"/col3=1/col4=2")
+ ){
+ resultPartitions.add(partition);
+ partitionId = partition.getPartitionId();
+ }
+ }
+ assertEquals(resultPartitions.size(), 1);
+ assertEquals(resultPartitions.get(0).getPartitionName(),
"col3=1/col4=2");
+
+ List<CatalogProtos.PartitionKeyProto> tablePartitionKeys =
catalog.getAllPartitionKeys();
+ List<CatalogProtos.PartitionKeyProto> resultPartitionKeys =
TUtil.newList();
+
+ for (CatalogProtos.PartitionKeyProto partitionKey: tablePartitionKeys)
{
+ if (partitionKey.getPartitionId() == partitionId
+ && (partitionKey.getColumnName().equals("col3") &&
partitionKey.getPartitionValue().equals("1")
+ || partitionKey.getColumnName().equals("col4") &&
partitionKey.getPartitionValue().equals("2"))) {
+ resultPartitionKeys.add(partitionKey);
+ }
+ }
+ assertEquals(resultPartitionKeys.size(), 2);
+ assertEquals(resultPartitionKeys.get(0).getColumnName(), "col3");
+ assertEquals(resultPartitionKeys.get(0).getPartitionValue(), "1");
+ assertEquals(resultPartitionKeys.get(1).getColumnName(), "col4");
+ assertEquals(resultPartitionKeys.get(1).getPartitionValue(), "2");
--- End diff --
Above tests looks duplicate with below tests. Only difference is that above
tests use catalog client APIs while below tests use tajo client APIs. For
consistency, I prefer to use tajo client APIs in this test class.
In addition, I think that we need to test the case when information of a
lot of partitions and partition keys is stored in catalog. So, it would be
great if more partitions are added when initializing.
> NPE when selecting data from information_schema.partition_keys
> --------------------------------------------------------------
>
> Key: TAJO-1675
> URL: https://issues.apache.org/jira/browse/TAJO-1675
> Project: Tajo
> Issue Type: Bug
> Components: Catalog
> Reporter: Jihoon Son
> Assignee: Jaehwa Jung
> Fix For: 0.11.0
>
>
> See the title.
> You can reproduce as follows.
> {noformat}
> default> create table partitioned_nation (n_name text, n_comment text)
> partition by column (n_nationkey int8, n_regionkey int8) ;
> OK
> default> insert into partitioned_nation select * from nation;
> default> \d partitioned_nation
> table name: default.partitioned_nation
> table uri: hdfs://localhost:7020/tajo/warehouse/default/partitioned_nation
> store type: CSV
> number of rows: 0
> volume: 0 B
> Options:
> 'text.delimiter'='|'
> schema:
> n_name TEXT
> n_comment TEXT
> Partitions:
> type:COLUMN
> columns::n_nationkey (INT8), n_regionkey (INT8)
> default> \c information_schema
> You are now connected to database "information_schema" as user "jihoonson".
> information_schema> select * from partition_keys;
> partition_id, column_name, partition_value
> -------------------------------
> ERROR: java.lang.NullPointerException
> java.sql.SQLException: java.lang.NullPointerException
> at
> org.apache.tajo.jdbc.TajoResultSetBase.next(TajoResultSetBase.java:717)
> at
> org.apache.tajo.cli.tsql.DefaultTajoCliOutputFormatter.printResult(DefaultTajoCliOutputFormatter.java:105)
> at
> org.apache.tajo.cli.tsql.TajoCli.localQueryCompleted(TajoCli.java:558)
> at org.apache.tajo.cli.tsql.TajoCli.executeQuery(TajoCli.java:532)
> at
> org.apache.tajo.cli.tsql.TajoCli.executeParsedResults(TajoCli.java:447)
> at org.apache.tajo.cli.tsql.TajoCli.runShell(TajoCli.java:419)
> at org.apache.tajo.cli.tsql.TajoCli.main(TajoCli.java:692)
> Caused by: java.io.IOException: java.lang.NullPointerException
> at org.apache.tajo.jdbc.FetchResultSet.nextTuple(FetchResultSet.java:80)
> at
> org.apache.tajo.jdbc.TajoResultSetBase.next(TajoResultSetBase.java:711)
> ... 6 more
> Caused by: com.google.protobuf.ServiceException:
> java.lang.NullPointerException
> at
> org.apache.tajo.client.QueryClientImpl.fetchNextQueryResult(QueryClientImpl.java:360)
> at
> org.apache.tajo.client.TajoClientImpl.fetchNextQueryResult(TajoClientImpl.java:134)
> at org.apache.tajo.jdbc.FetchResultSet.nextTuple(FetchResultSet.java:62)
> ... 7 more
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)