zazuko / query-rdf-data-cube

Explore or query RDF Data Cubes with a JavaScript API, without writing SPARQL.
https://zazuko.github.io/query-rdf-data-cube/
9 stars 2 forks source link

datacube.select() always returns all dimensions #25

Open lucguillemot opened 4 years ago

lucguillemot commented 4 years ago

When running a query like this

const query = datacube
  .query()
  .select({
    measurement: measures[0],
    ageGroup: dimensions[3],
  })

I would expect the returned data to only contain the named dimension ageGroup and the associated measurement.

Actually, the returned data does contain the named dimension and the measure, but also includes all the other dimensions with a generated name tmpVar1, tmpVar2, etc. Is it the desired behavior? I'm using v.0.0.10.

Thanks!

ktk commented 4 years ago

This is IMO intended behavior, I would expect that I always get all dimensions back as from a RDF Data Cube vocabulary perspective, they are all mandatory.

Could you explain on an example on why you would expect to get just the referenced dimension back? Maybe we are missing something here but I can't follow so far.

jstcki commented 4 years ago

What's the purpose of explicitly using .select then?

One example that doesn't work if dimensions are "auto-selected" would be to get all DISTINCT values of one dimension:

query.select({ageGroup: ageGroupDim}).distinct()

… currently this returns too many values because DISTINCT is applied to all variable combinations.

Or: If we filter by one dimension, we don't necessarily need to .select it anymore (we may want to but would like to stay in control). By selecting less fields, we also expect to fetch less data, which is more efficient.

In general it's just unexpected and confusing that using .select doesn't really align with what's SELECTed.

...

Maybe if this library is intended to deviate from SPARQL more, then actually .select should be removed altogethe?

vhf commented 4 years ago

Honestly I don't like this approach either, automagically adding things to the select doesn't feel right API-wise.