implydata / plywood

A toolkit for querying and interacting with Big Data

Home Page:https://plywood.imply.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parent Dataset Attribute Not Resolving

robertervin opened this issue · comments

In

Plywood.ply()
      .apply("my_datasource", $("my_datasource")
            .filter($("timestamp").in({start: new Date("2018-01-01"), end: new Date() }))
            .split({UserId: '$user__id'}, 'visitorTypes')
            .apply('user__is_new', $("my_datasource").max('$user__is_first_session'))
            .filter($('user__id').in($('visitorTypes').filter($('user__is_new').is(0)).collect($('UserId'))))
      )
      .apply('data', $("my_datasource").count())

Plywood throws

Error: could not resolve $user__id

on

if (!myTypeContext) {

So what is happening here (taken at face value) is that the .filter($('user__id')... clause is after the split. There is no user__id on that dataset, which should have UserId, visitorTypes, user__is_new defined at that point. What is the intention of the second filter?

Yep good point. As I've progressed in Plywood and gotten a better idea of how it works, I realized this makes little sense.

The second filter is intended to filter the main datasource to only returning users (e.g. users who have no first sessions in the time range).

I've since refactored it to be more like

Plywood.ply()
      .apply("Users", $("my_datasource")
            .filter($("timestamp").in({start: new Date("2018-01-01"), end: new Date() }))
            .split({UserId: '$user__id'}, 'visitorTypes')
            .apply('user__is_new', $("my_datasource").max('$user__is_first_session'))
      )
      .apply("returning_users", $("my_datasource").filter('$user__id in [$Users.filter($user__is_new=0).collect($UserId)]')
      .apply("new_users", $("my_datasource").filter('$user__id in [$Users.filter($user__is_new=1).collect($UserId)]')

Will close the issue since Plywood is working in only logical way, and it simply a learning curve I had to overcome.