malloydata / malloy

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

Joined filtered Sources #1883

Closed lloydtabb closed 2 months ago

lloydtabb commented 2 months ago

In Presto, the code below would fail because we complicate joining of sources with where clauses always using the the more complex path to avoid SQL errors.

We now just use the simple path for Presto but we probably need to add better error checking or another strategy. See the notes in the code.

This is a blocker so I'm going to land and revisit.

     source: sf is ${databaseName}.table('malloytest.state_facts') extend {
        measure: state_count is count()
        primary_key: state
      }

      source: al is sf extend {where: state = 'AL'}

      source: a is sf extend {
        where: state ~ 'A%'
        join_one: al with state
      }

      source: allx is sf extend {
        join_one: a with state
      }
      // # test.debug
      run: allx -> {
        aggregate:
          allx is state_count
          a is a.state_count
          al is a.al.state_count