Groupby Pivot in Materialized View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 11:45 AM - edited 02-24-2023 11:51 AM
Hello,
I am trying to create a materialized view with pyspark where I change the shape of a dataframe using a groupby and pivot function to create many new columns out of a pre existing column.
Like so:
result = df.groupby("ItemId").pivot("Question").agg(first("Answer", ignorenulls = True))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 02:38 PM
Hello,
I have had this problem when new values are added in the source data. The key for me was to force Incorta to think the script was different so it discovers the new "columns". I add a # on an empty line and it's enough to be different and pull in the new fields. The next time it happens I take the # out of the script for the next "change". Keep going back and forth each time the underlying data changes.
Ryan
