Skip to content

Commit

Permalink
Merge branch 'pr/feature/optimize-sparql-query-build-unions' into dev…
Browse files Browse the repository at this point in the history
…elopment
  • Loading branch information
syphax-bouazzouni committed Nov 23, 2022
2 parents 835aefa + 6cf7320 commit ad48ecf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/goo/sparql/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def build_select_query(ids, variables, graphs, patterns,
variables, optional_patterns = get_aggregate_vars(@aggregate, @collection, graphs,
@klass, @unions, variables, internal_variables)

@order_by, variables, patterns = init_order_by(@count, @klass, @order_by, patterns, variables)
@order_by, variables, @unions = init_order_by(@count, @klass, @order_by, @unions, variables)
variables, patterns = add_some_type_to_id(patterns, query_options, variables)

query_filter_str, patterns, optional_patterns =
Expand Down Expand Up @@ -258,19 +258,20 @@ def get_client
Goo.sparql_query_client(@store)
end

def init_order_by(count, klass, order_by, patterns, variables)
def init_order_by(count, klass, order_by, unions, variables)
order_by = nil if count
if order_by
order_by = order_by.first
#simple ordering ... needs to use pattern inspection
order_by.each do |attr, direction|
quad = query_pattern(klass, attr)
patterns << quad[1]
unions << [quad[1]]
#patterns << quad[1]
#mdorf, 9/22/16 If an ORDER BY clause exists, the columns used in the ORDER BY should be present in the SPARQL select
variables << attr unless variables.include?(attr)
end
end
[order_by, variables, patterns]
[order_by, variables, unions]
end

def sparql_op_string(op)
Expand Down

0 comments on commit ad48ecf

Please sign in to comment.