malloydata / malloy

Malloy is an experimental language for describing data relationships and transformations.
http://www.malloydata.dev
MIT License
1.95k stars 75 forks source link

Redfining a query in an redefined source should replace it. #901

Open lloydtabb opened 1 year ago

lloydtabb commented 1 year ago

Or we should argue about it...

source: a is .. {
  query: bar is { ... }
}

source: b is a + {
  query: bar is { ... }   // redefinition error.
}
mtoy-googly-moogly commented 1 year ago

We can talk about true refinements at some point,(leaving this open as a placeholder)

Today you write that like this:

source: refineMe is table('malloy-data.faa.flights') {
  dimension: flight_count is count()
  query: by_carrier is {
    aggregate: flight_count
    group_by: carrier
  }
}

source: flights is refineMe {
  except: by_carrier
  query: by_carrier is {
    group_by: carrier
    aggregate: flight_count
  }
}

accept/except aren't great, they just exist so it is possible to write things before the day comes when we invent a lovely syntax for refinements

you could also do ... (i think, none of this is well tested)

source: flights is refineMe {
 rename: old_by_carrier is by_carrier
  query: by_carrier is old_by_carrier {
    group_by: destination
  }
}