Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrowthBook Support #9087

Open
itestyoy opened this issue Jan 9, 2025 · 4 comments
Open

GrowthBook Support #9087

itestyoy opened this issue Jan 9, 2025 · 4 comments
Assignees
Labels
question The issue is a question. Please use Stack Overflow for questions.

Comments

@itestyoy
Copy link

itestyoy commented Jan 9, 2025

Hi! Is it possible to integrate GrowthBook as a BI tool using the Cube SQL API?

@igorlukanin igorlukanin added the question The issue is a question. Please use Stack Overflow for questions. label Jan 9, 2025
@igorlukanin
Copy link
Member

I see in their docs that they have some support for Postgres connections so it might work. However, I don't have a really strong opinion here since I'm unfamiliar with GrowthBook as a product and have no first-hand experience with it.

Did you try connection it to Cube? What worked and what did not?

@igorlukanin igorlukanin self-assigned this Jan 9, 2025
@itestyoy
Copy link
Author

itestyoy commented Jan 9, 2025

Hi @igorlukanin!

In general all queries look like this

QUERY:

-- Ad Revenue (Cube) (revenue)
WITH
  __rawExperiment AS (
    SELECT
      *
    from
      players
  ),
  __experimentExposures AS (
    -- Viewed Experiment
    SELECT
      e.user_id as user_id,
      cast(e.variation_id as varchar) as variation,
      e.timestamp as timestamp
    FROM
      __rawExperiment e
    WHERE
      e.experiment_id = 'android_daily_tasks_rv_reward'
      AND e.timestamp >= '2024-12-27 00:00:00'
      AND e.timestamp <= '2025-01-09 13:11:25'
  ),
  __experimentUnits AS (
    -- One row per user
    SELECT
      e.user_id AS user_id,
      (
        CASE
          WHEN count(distinct e.variation) > 1 THEN '__multiple__'
          ELSE max(e.variation)
        END
      ) AS variation,
      MIN(e.timestamp) AS first_exposure_timestamp
    FROM
      __experimentExposures e
    GROUP BY
      e.user_id
  ),
  __distinctUsers AS (
    SELECT
      user_id,
      cast('' as varchar) AS dimension,
      variation,
      first_exposure_timestamp AS timestamp,
      date_trunc('day', first_exposure_timestamp) AS first_exposure_date
    FROM
      __experimentUnits
  ),
  __metric as ( -- Metric (Ad Revenue (Cube))
    SELECT
      user_id as user_id,
      m.value as value,
      m.timestamp as timestamp
    FROM
      (
        SELECT
          *
        FROM
          monetization
      ) m
    WHERE
      m.timestamp >= '2024-12-27 00:00:00'
      AND m.timestamp <= '2025-01-09 13:11:25'
  ),
  __userMetricJoin as (
    SELECT
      d.variation AS variation,
      d.dimension AS dimension,
      d.user_id AS user_id,
      (
        CASE
          WHEN m.timestamp >= d.timestamp
          AND m.timestamp <= '2025-01-09 13:11:25' THEN m.value
          ELSE NULL
        END
      ) as value
    FROM
      __distinctUsers d
      LEFT JOIN __metric m ON (m.user_id = d.user_id)
  ),
  __userMetricAgg as (
    -- Add in the aggregate metric value for each user
    SELECT
      umj.variation AS variation,
      umj.dimension AS dimension,
      umj.user_id,
      SUM(COALESCE(value, 0)) as value
    FROM
      __userMetricJoin umj
    GROUP BY
      umj.variation,
      umj.dimension,
      umj.user_id
  )
  -- One row per variation/dimension with aggregations
SELECT
  m.variation AS variation,
  m.dimension AS dimension,
  COUNT(*) AS users,
  SUM(COALESCE(m.value, 0)) AS main_sum,
  SUM(POWER(COALESCE(m.value, 0), 2)) AS main_sum_squares
FROM
  __userMetricAgg m
GROUP BY
  m.variation,
  m.dimension

but we got error
Error during rewrite: Use __cubeJoinField to join Cubes. Please check logs for additional information.

CTE parts __rawExperiment, __metric are cube query

@itestyoy
Copy link
Author

Without sql push down error looks like

Error during planning: 'Timestamp(Nanosecond, None) <= Utf8' can't be evaluated because there isn't a common type to coerce the types to

@igorlukanin
Copy link
Member

but we got error
Error during rewrite: Use __cubeJoinField to join Cubes.

All right, so it looks like this one is blocked by this feature (part of Cube Core roadmap): #8483

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue is a question. Please use Stack Overflow for questions.
Projects
None yet
Development

No branches or pull requests

2 participants