Skip to content

Commit

Permalink
Bugfix; missing column variables in dhformulacolumn
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Feb 10, 2024
1 parent 0297271 commit f97fbf8
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static QueryLanguageParser.Result getCompiledFormula(Map<String, ColumnDe
final Map<String, Class<?>[]> possibleVariableParameterizedTypes = new HashMap<>();

for (ColumnDefinition<?> columnDefinition : availableColumns.values()) {
// add column-vectors
final String columnSuffix = DhFormulaColumn.COLUMN_SUFFIX;
final Class<?> vectorType = DhFormulaColumn.getVectorType(columnDefinition.getDataType());

Expand All @@ -92,12 +93,25 @@ public static QueryLanguageParser.Result getCompiledFormula(Map<String, ColumnDe
possibleVariableParameterizedTypes.put(columnDefinition.getName() + columnSuffix,
new Class[] {columnDefinition.getDataType()});
}

// add columns
columnVariables.add(columnDefinition.getName());
possibleVariables.put(columnDefinition.getName(), columnDefinition.getDataType());
final Class<?> compType = columnDefinition.getComponentType();
if (compType != null && !compType.isPrimitive()) {
possibleVariableParameterizedTypes.put(columnDefinition.getName(), new Class[] {compType});
}
}

final ExecutionContext context = ExecutionContext.getContext();
final Map<String, Object> queryScopeVariables = context.getQueryScope().toMap(
NameValidator.VALID_QUERY_PARAMETER_MAP_ENTRY_PREDICATE);
for (Map.Entry<String, Object> param : queryScopeVariables.entrySet()) {
if (possibleVariables.containsKey(param.getKey())) {
// skip any existing matches
continue;
}

possibleVariables.put(param.getKey(), QueryScopeParamTypeUtil.getDeclaredClass(param.getValue()));

Type declaredType = QueryScopeParamTypeUtil.getDeclaredType(param.getValue());
Expand All @@ -110,16 +124,6 @@ public static QueryLanguageParser.Result getCompiledFormula(Map<String, ColumnDe
}
}

for (ColumnDefinition<?> columnDefinition : availableColumns.values()) {
if (possibleVariables.put(columnDefinition.getName(), columnDefinition.getDataType()) != null) {
possibleVariableParameterizedTypes.remove(columnDefinition.getName());
}
final Class<?> compType = columnDefinition.getComponentType();
if (compType != null && !compType.isPrimitive()) {
possibleVariableParameterizedTypes.put(columnDefinition.getName(), new Class[] {compType});
}
}

// log.debug().append("Expression (before) : ").append(formulaString).endl();

log.debug().append("Expression (after time conversion) : ").append(timeConversionResult.getConvertedFormula())
Expand Down

0 comments on commit f97fbf8

Please sign in to comment.