Skip to content

Instantly share code, notes, and snippets.

@mibrahim
Created September 21, 2014 00:07
Show Gist options
  • Save mibrahim/6ebbd254412a3648ad7e to your computer and use it in GitHub Desktop.
Save mibrahim/6ebbd254412a3648ad7e to your computer and use it in GitHub Desktop.
Issue with maintaining index with not null
0: jdbc:phoenix:localhost> create table test.testing(k integer primary key, v bigint not null);
No rows affected (2.547 seconds)
0: jdbc:phoenix:localhost> upsert into test.testing(k,v) values(1, 5);
1 row affected (0.014 seconds)
0: jdbc:phoenix:localhost> select * from test.testing;
+------------+------------+
| K | V |
+------------+------------+
| 1 | 5 |
+------------+------------+
1 row selected (0.103 seconds)
0: jdbc:phoenix:localhost> create index idx1 on test.testing(v);
1 row affected (2.455 seconds)
0: jdbc:phoenix:localhost> select * from test.testing;
+------------+------------+
| K | V |
+------------+------------+
| 1 | 5 |
+------------+------------+
1 row selected (0.109 seconds)
0: jdbc:phoenix:localhost> upsert into test.testing(k,v) values(1, 6);
1 row affected (0.074 seconds)
0: jdbc:phoenix:localhost> select * from test.testing;
+------------+------------+
| K | V |
+------------+------------+
| 1 | 5 |
| null | null |
+------------+------------+
2 rows selected (0.109 seconds)
0: jdbc:phoenix:localhost> select k, v from test.testing where v>0;
+------------+------------+
| K | V |
+------------+------------+
| 1 | 5 |
| null | null |
+------------+------------+
2 rows selected (0.119 seconds)
0: jdbc:phoenix:localhost> explain select k, v from test.testing where v>0;
+------------+
| PLAN |
+------------+
| CLIENT PARALLEL 1-WAY RANGE SCAN OVER TEST.IDX1 [1] - [*] |
+------------+
1 row selected (0.069 seconds)
0: jdbc:phoenix:localhost> drop index idx1 on test.testing;
No rows affected (2.579 seconds)
0: jdbc:phoenix:localhost> upsert into test.testing(k,v) values(1, 6);
1 row affected (0.014 seconds)
0: jdbc:phoenix:localhost> select * from test.testing;
+------------+------------+
| K | V |
+------------+------------+
| 1 | 6 |
+------------+------------+
1 row selected (0.121 seconds)
0: jdbc:phoenix:localhost> drop table test.testing;
#### Actually the table gets dropped, but I always get this exception
14/09/20 20:01:54 WARN client.HConnectionManager$HConnectionImplementation: Encountered problems when prefetch META table:
org.apache.hadoop.hbase.TableNotFoundException: Cannot find row in .META. for table: _IDX_TEST.TESTING, row=_IDX_TEST.TESTING,,99999999999999
at org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:151)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.prefetchRegionCache(HConnectionManager.java:1059)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1121)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:1001)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:958)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:251)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:243)
at org.apache.phoenix.query.HTableFactory$HTableFactoryImpl.getTable(HTableFactory.java:51)
at org.apache.phoenix.query.ConnectionQueryServicesImpl.getTable(ConnectionQueryServicesImpl.java:249)
at org.apache.phoenix.query.ConnectionQueryServicesImpl.getTableDescriptor(ConnectionQueryServicesImpl.java:261)
at org.apache.phoenix.util.MetaDataUtil.hasViewIndexTable(MetaDataUtil.java:269)
at org.apache.phoenix.schema.MetaDataClient.dropTable(MetaDataClient.java:1303)
at org.apache.phoenix.schema.MetaDataClient.dropTable(MetaDataClient.java:1244)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableDropTableStatement$1.execute(PhoenixStatement.java:519)
at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:226)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:919)
at sqlline.SqlLine$Commands.execute(SqlLine.java:3673)
at sqlline.SqlLine$Commands.sql(SqlLine.java:3584)
at sqlline.SqlLine.dispatch(SqlLine.java:821)
at sqlline.SqlLine.begin(SqlLine.java:699)
at sqlline.SqlLine.mainWithInputRedirection(SqlLine.java:441)
at sqlline.SqlLine.main(SqlLine.java:424)
No rows affected (2.873 seconds)
0: jdbc:phoenix:localhost> create table test.testing(k integer primary key, v bigint);
No rows affected (2.517 seconds)
0: jdbc:phoenix:localhost> create index idx1 on test.testing(v);
No rows affected (1.502 seconds)
0: jdbc:phoenix:localhost> upsert into test.testing(k,v) values(1, 5);
1 row affected (0.182 seconds)
0: jdbc:phoenix:localhost> select * from test.testing;
+------------+------------+
| K | V |
+------------+------------+
| 1 | 5 |
+------------+------------+
1 row selected (1.091 seconds)
0: jdbc:phoenix:localhost> upsert into test.testing(k,v) values(1, 6);
1 row affected (0.064 seconds)
0: jdbc:phoenix:localhost> select * from test.testing;
+------------+------------+
| K | V |
+------------+------------+
| 1 | 6 |
+------------+------------+
1 row selected (0.102 seconds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment