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

[persistence] make queries work with postgres #2810

Closed
Tracked by #1689
mikeldking opened this issue Apr 8, 2024 · 3 comments
Closed
Tracked by #1689

[persistence] make queries work with postgres #2810

mikeldking opened this issue Apr 8, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@mikeldking
Copy link
Contributor

mikeldking commented Apr 8, 2024

Currently the postgres dialect and sqlite dialect conflict. Notably with postgres:

Error fetching GraphQL query 'ProjectPageQuery' with variables '{"id":"UHJvamVjdDow"}': [{"message":"(sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.CannotCoerceError'>: cannot cast type json to integer\n[SQL: SELECT coalesce(sum(CAST((spans.attributes -> $1::TEXT) AS INTEGER)), $2::INTEGER) + coalesce(sum(CAST((spans.attributes -> $3::TEXT) AS INTEGER)), $4::INTEGER) AS anon_1 \nFROM spans JOIN traces ON traces.id = spans.trace_rowid JOIN projects ON projects.id = traces.project_rowid \nWHERE projects.name = $5::VARCHAR]\n[parameters: ('llm.token_count.prompt', 0, 'llm.token_count.completion', 0, 'default')]\n(Background on this error at: https://sqlalche.me/e/20/f405)","locations":[{"line":17,"column":3}],"path":["project","tokenCountTotal"]}]
@github-project-automation github-project-automation bot moved this to 📘 Todo in phoenix Apr 8, 2024
@dosubot dosubot bot added the enhancement New feature or request label Apr 8, 2024
@mikeldking
Copy link
Contributor Author

Inserts failing as well

DEBUG [urllib3.connectionpool] http://0.0.0.0:6006 "POST /v1/traces HTTP/1.1" 500 10359
DEBUG [urllib3.connectionpool] Resetting dropped connection: 0.0.0.0
INFO  [sqlalchemy.engine.Engine] BEGIN (implicit)
INFO  [sqlalchemy.engine.Engine] SELECT projects.id 
FROM projects 
WHERE projects.name = $1::VARCHAR
INFO  [sqlalchemy.engine.Engine] [cached since 31.26s ago] ('default',)
DEBUG [sqlalchemy.engine.Engine] Col ('id',)
DEBUG [sqlalchemy.engine.Engine] Row (1,)
INFO  [sqlalchemy.engine.Engine] 
                INSERT INTO traces(trace_id, project_rowid, session_id, start_time, end_time)
                VALUES($1, $2, $3, $4, $5)
                ON CONFLICT DO UPDATE SET
                start_time = CASE WHEN excluded.start_time < start_time THEN excluded.start_time ELSE start_time END,
                end_time = CASE WHEN end_time < excluded.end_time THEN excluded.end_time ELSE end_time END
                WHERE excluded.start_time < start_time OR end_time < excluded.end_time
                RETURNING rowid;
                
INFO  [sqlalchemy.engine.Engine] [cached since 31.24s ago] ('a29462e5e07542c68aba5307238ea274', 1, None, datetime.datetime(2023, 12, 11, 17, 47, 46, 621154, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 12, 11, 17, 47, 46, 772126, tzinfo=datetime.timezone.utc))
INFO  [sqlalchemy.engine.Engine] ROLLBACK

@mikeldking
Copy link
Contributor Author

Might be a discrepancy on the conflict name requirement for postgres

(sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.PostgresSyntaxError'>: ON CONFLICT DO UPDATE requires inference specification or constraint name
HINT:  For example, ON CONFLICT (column_name).
[SQL: 
                INSERT INTO traces(trace_id, project_rowid, session_id, start_time, end_time)
                VALUES($1, $2, $3, $4, $5)
                ON CONFLICT DO UPDATE SET
                start_time = CASE WHEN excluded.start_time < start_time THEN excluded.start_time ELSE start_time END,
                end_time = CASE WHEN end_time < excluded.end_time THEN excluded.end_time ELSE end_time END
                WHERE excluded.start_time < start_time OR end_time < excluded.end_time
                RETURNING rowid;
                ]
[parameters: ('8f87ad1213cd4833a18c97b46faac8ad', 1, None, datetime.datetime(2023, 12, 11, 17, 48, 17, 246825, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 12, 11, 17, 48, 26, 519123, tzinfo=datetime.timezone.utc))]

@mikeldking
Copy link
Contributor Author

this is actually completed

@github-project-automation github-project-automation bot moved this from 📘 Todo to ✅ Done in phoenix Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

2 participants