-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix mixed goals conversions crash #6049
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved too early.
I think there's a logical error still in the conversions calculation that depends on the order in which goals are inserted (and therefore returned from SELECT?).
Anyways, see the failing test below:
It passes when I move the creation of the Purchase - All goal to be the first goal created in the setup.
Stumbled upon this pretty randomly, wanted to see if things still work when the goal with and without custom props is on the same event_name. The customer where it blew up was using custom props to narrow down the Outbound Link: Click goal to a specific url they care about but it's valid to keep the goal for the generic event as well.
|
@ruslandoga 👋 solution in this PR is trying to work around https://github.com/plausible/ecto_ch/blob/9a517fe9eff14c1cfae6fc8e0c6ebfe372b032e6/lib/ecto/adapters/clickhouse/connection.ex#L1234 The desperate fix would be something like: defmacro event_goal_join(goal_join_data) do
quote do
@@ -467,8 +474,8 @@ defmodule Plausible.Stats.SQL.Expression do
?,
?,
?,
- ?,
- ?
+ arraySlice(?, 2),
+ arraySlice(?, 2)
)
)
""",
@@ -481,8 +488,14 @@ defmodule Plausible.Stats.SQL.Expression do
type(^unquote(goal_join_data).event_names_by_type, {:array, :string}),
type(^unquote(goal_join_data).scroll_thresholds, {:array, :integer}),
type(^unquote(goal_join_data).indices, {:array, :integer}),
- type(^unquote(goal_join_data).custom_props_keys, {:array, {:array, :string}}),
- type(^unquote(goal_join_data).custom_props_values, {:array, {:array, :string}})
+ type(
+ ^[["__TRICK_ECTO_CH__"] | unquote(goal_join_data).custom_props_keys],
+ {:array, {:array, :string}}
+ ),
+ type(
+ ^[["__TRICK_ECTO_CH__"] | unquote(goal_join_data).custom_props_values],
+ {:array, {:array, :string}}
+ )
)
end
endDo you think you know how to properly fix this at source? |
|
👋 @aerosol I think it's time to do that TODO. I'd like to open a PR with something like this, but maybe a bit cleaner: defp param_type([]), do: "Array(Nothing)"
defp param_type([v | vs]) do
param_type = param_type(v)
if param_type == "Array(Nothing)" do
param_type(vs)
else
["Array(", param_type, ?)]
end
end |
Tracking the core issue at plausible/ecto_ch#262
|
@ukutaht awful workaround implemented to unblock customers. Tracking ecto_ch at plausible/ecto_ch#262 |
Changes
When goals with custom properties are mixed with goals without custom properties, ecto_ch only checks the first element of an array to infer its type. When goals are ordered such that those without custom props come first in the array, the custom_props_keys array looks like:
[[],[],[],['url']]which results withArray(Nothing), which causes ClickHouse to fail with:Tests
Changelog
Documentation
Dark mode