Skip to content

Commit a0c5ec6

Browse files
committed
DS-1723,DS-1841:
* Temp. fix PSQLIndexIT test * OnDemandIndex.transformIntoNewDefinition() remove "f." from Expression Signed-off-by: mchrza <[email protected]>
1 parent e1804f5 commit a0c5ec6

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

xyz-models/src/main/java/com/here/xyz/models/hub/Space.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ private NormalizedProperty tryParseNewStyleKey(String key) {
725725
* - "foo::array"
726726
*/
727727
private NormalizedProperty parseLegacyKey(String key) {
728-
String base = key.startsWith("f.") ? key : "properties." + key;
728+
String base = key.startsWith("f.") ? key.substring("f.".length()) : "properties." + key;
729729
String resultType = "scalar"; //default
730730

731731
int sepIdx = key.lastIndexOf("::");
@@ -753,6 +753,8 @@ private NormalizedProperty parseLegacyKey(String key) {
753753
String alias;
754754
if (expression.startsWith("$.") && expression.length() > 2) {
755755
alias = expression.substring(2);
756+
if(!alias.startsWith("properties."))
757+
alias = "f." + alias;
756758
}
757759
else if (expression.startsWith("$") && expression.length() > 1) {
758760
alias = expression.substring(1);

xyz-psql-connector/src/test/java/com/here/xyz/psql/PSQLIndexIT.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void testOnDemandIdxCreation() throws Exception {
195195
assertEquals("s",resultSet.getString("src"));
196196
}
197197
else {
198-
searchableProperties.remove(idxProperty);
198+
searchableProperties.remove(idxProperty.substring("properties.".length()));
199199
assertEquals("m",resultSet.getString("src"));
200200
}
201201

@@ -215,9 +215,8 @@ public void testOnDemandIdxCreation() throws Exception {
215215

216216
List<StatisticsResponse.PropertyStatistics> propStatistics = resp.getProperties().getValue();
217217
for (StatisticsResponse.PropertyStatistics propStat: propStatistics ) {
218-
assertEquals("foo",propStat.getKey().substring(0,3));
219-
// TODO: Clarify Behavior (StatisticsResponse)
220-
//assertNull(propStat.isSearchable());
218+
//TODO: Discuss BWC !
219+
assertEquals("foo",propStat.getKey().replace("properties.","").substring(0,3));
221220
}
222221
}
223222

xyz-util/src/main/java/com/here/xyz/util/db/pg/IndexHelper.java

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -215,34 +215,18 @@ public void transformIntoNewDefinition() {
215215
}
216216
}
217217

218+
String alias = path;
218219
if(!path.startsWith("f."))
219-
path = "properties."+path;
220+
alias = path = "properties."+path;
221+
else
222+
path = path.substring("f.".length());
220223

221-
propertyPath = "$" + path + ":[$." + path + "]::" + datatype;
224+
propertyPath = "$" + alias + ":[$." + path + "]::" + datatype;
222225
}
223226

224227
public boolean definitionGotTransformed() {
225228
String alias = extractAlias();
226-
if(alias.equals(extractLogicalPropertyPath())){
227-
if(alias.startsWith("properties.") || alias.startsWith("f."))
228-
return true;
229-
return true;
230-
}
231-
return false;
232-
// propertyPath = propertyPath.trim();
233-
// int colonIndex = propertyPath.indexOf(':');
234-
//
235-
// String leftPath = propertyPath.substring(1, colonIndex);
236-
//
237-
// int openBracket = propertyPath.indexOf("[$.");
238-
// int closeBracket = propertyPath.indexOf("]", openBracket);
239-
//
240-
// String inner = propertyPath.substring(openBracket + 3, closeBracket);
241-
//
242-
//
243-
//
244-
// // Compare paths
245-
// return leftPath.equals(inner);
229+
return alias.startsWith("f.") || alias.startsWith("properties.");
246230
}
247231

248232
@Override
@@ -294,7 +278,6 @@ public static List<OnDemandIndex> getActivatedSearchableProperties(Map<String, B
294278
public static SQLQuery buildOnDemandIndexCreationQuery(String schema, String table, OnDemandIndex index, TableLayout layout, boolean async){
295279
if(layout.hasSearchableColumn())
296280
return buildOnDemandIndexCreationQuery(schema, table, index.extractAlias(), NEW_LAYOUT_INDEX_COULMN, async);
297-
index.definitionGotTransformed();
298281
return buildOnDemandIndexCreationQuery(schema, table, index.extractLogicalPropertyPath(), OLD_LAYOUT_INDEX_COULMN, async);
299282
}
300283

0 commit comments

Comments
 (0)