ranganathg commented on code in PR #1708:
URL: https://github.com/apache/phoenix/pull/1708#discussion_r1365039969
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/json/JsonFunctionsIT.java:
##########
@@ -633,4 +637,34 @@ public void testJsonQuery() throws Exception {
compareJson(rs.getString(5), JsonDatatypes,
"$.datatypes.mixedArray");
}
}
+
+ @Test
+ public void testExpressionIndex() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ String tableName = generateUniqueName();
+ String indexName = "IDX_" + generateUniqueName();
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.setAutoCommit(true);
+ String
+ ddl =
+ "create table if not exists " + tableName +
+ " (pk integer primary key, col integer,
jsoncol.jsoncol json)";
+ conn.createStatement().execute(ddl);
+ conn.createStatement().execute(
+ "UPSERT INTO " + tableName + " (pk, col, jsoncol) VALUES
(1,2, '" + JsonDoc1 + "')");
+ conn.createStatement().execute(
+ "CREATE INDEX " + indexName + " ON " + tableName
+ + " (JSON_VALUE(JSONCOL,'$.type'),
JSON_VALUE(JSONCOL,'$.info.address.town')) include (col)");
+ String
+ selectSql =
+ "SELECT JSON_VALUE(JSONCOL,'$.type'), " +
+ "JSON_VALUE(JSONCOL,'$.info.address.town') FROM " +
tableName +
+ " WHERE JSON_VALUE(JSONCOL,'$.type') = 'Basic'";
+ ResultSet rs = conn.createStatement().executeQuery("EXPLAIN " +
selectSql);
+ String actualExplainPlan = QueryUtil.getExplainPlan(rs);
+ IndexToolIT.assertExplainPlan(false, actualExplainPlan, tableName,
indexName);
+ } catch (SQLException e) {
+ assertEquals(SQLExceptionCode.DIVIDE_BY_ZERO.getErrorCode(),
e.getErrorCode());
Review Comment:
Fixed this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]