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

[OPIK-446] remove materialized column #916

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,10 @@ LEFT JOIN (
private static final String SELECT_BY_ID = """
SELECT
*,
duration_millis
if(end_time IS NOT NULL AND start_time IS NOT NULL
AND notEquals(start_time, toDateTime64('1970-01-01 00:00:00.000', 9)),
(dateDiff('microsecond', start_time, end_time) / 1000.0),
NULL) AS duration_millis
FROM
spans
WHERE id = :id
Expand Down Expand Up @@ -513,7 +516,10 @@ LEFT JOIN (
last_updated_at,
created_by,
last_updated_by,
duration_millis
if(end_time IS NOT NULL AND start_time IS NOT NULL
AND notEquals(start_time, toDateTime64('1970-01-01 00:00:00.000', 9)),
(dateDiff('microsecond', start_time, end_time) / 1000.0),
NULL) AS duration_millis
FROM spans
WHERE project_id = :project_id
AND workspace_id = :workspace_id
Expand Down Expand Up @@ -636,7 +642,10 @@ AND id in (
workspace_id,
project_id,
id,
duration_millis,
if(end_time IS NOT NULL AND start_time IS NOT NULL
AND notEquals(start_time, toDateTime64('1970-01-01 00:00:00.000', 9)),
(dateDiff('microsecond', start_time, end_time) / 1000.0),
NULL) AS duration_millis,
if(length(input) > 0, 1, 0) as input_count,
if(length(output) > 0, 1, 0) as output_count,
if(length(metadata) > 0, 1, 0) as metadata_count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ INSERT INTO traces (
FROM (
SELECT
*,
duration_millis
if(end_time IS NOT NULL AND start_time IS NOT NULL
AND notEquals(start_time, toDateTime64('1970-01-01 00:00:00.000', 9)),
(dateDiff('microsecond', start_time, end_time) / 1000.0),
NULL) AS duration_millis
FROM traces
WHERE workspace_id = :workspace_id
AND id = :id
Expand Down Expand Up @@ -321,7 +324,10 @@ LEFT JOIN (
last_updated_at,
created_by,
last_updated_by,
duration_millis
if(end_time IS NOT NULL AND start_time IS NOT NULL
AND notEquals(start_time, toDateTime64('1970-01-01 00:00:00.000', 9)),
(dateDiff('microsecond', start_time, end_time) / 1000.0),
NULL) AS duration_millis
FROM traces
WHERE project_id = :project_id
AND workspace_id = :workspace_id
Expand Down Expand Up @@ -620,7 +626,10 @@ LEFT JOIN (
workspace_id,
project_id,
id,
duration_millis,
if(end_time IS NOT NULL AND start_time IS NOT NULL
AND notEquals(start_time, toDateTime64('1970-01-01 00:00:00.000', 9)),
(dateDiff('microsecond', start_time, end_time) / 1000.0),
NULL) AS duration_millis,
if(length(input) > 0, 1, 0) as input_count,
if(length(output) > 0, 1, 0) as output_count,
if(length(metadata) > 0, 1, 0) as metadata_count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ public class FilterQueryBuilder {
private static final String USAGE_PROMPT_TOKENS_ANALYTICS_DB = "usage['prompt_tokens']";
private static final String USAGE_TOTAL_TOKENS_ANALYTICS_DB = "usage['total_tokens']";
private static final String VALUE_ANALYTICS_DB = "value";
private static final String DURATION_ANALYTICS_DB = "duration_millis";
private static final String DURATION_ANALYTICS_DB = """
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrescrz, this is done as a quick fix. I will make a proper fix in a later PR

if(end_time IS NOT NULL AND start_time IS NOT NULL
AND notEquals(start_time, toDateTime64('1970-01-01 00:00:00.000', 9)),
(dateDiff('microsecond', start_time, end_time) / 1000.0),
NULL)
""";

private static final Map<Operator, Map<FieldType, String>> ANALYTICS_DB_OPERATOR_MAP = new EnumMap<>(Map.of(
Operator.CONTAINS, new EnumMap<>(Map.of(
Expand Down

This file was deleted.

Loading