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

[Data] Support write_sql() #38242

Closed
c21 opened this issue Aug 9, 2023 · 0 comments · Fixed by #38544
Closed

[Data] Support write_sql() #38242

c21 opened this issue Aug 9, 2023 · 0 comments · Fixed by #38544
Assignees
Labels
data Ray Data-related issues P1 Issue that should be fixed within a few weeks Ray 2.7

Comments

@c21
Copy link
Contributor

c21 commented Aug 9, 2023

Description

For LLM application, it's often needed to write vector index back to database, e.g. https://github.com/pgvector/pgvector.
It would be great if Ray Data supports writing to the SQL database, then we can work with the index end-to-end smoothly.

The interface can be

def write_sql(
    self,
    sql: str,
    connection_factory: Callable[[], Connection],
    ray_remote_args: Optional[Dict[str, Any]] = None,
) -> None:
from pgvector.psycopg import register_vector

# you can do following
def create_connection():
    conn = psycopg.connect(os.environ["DB_CONNECTION_STRING"])
    register_vector(conn)
    return conn

ds = ...
ds.write_sql("INSERT INTO document (uri, body, embedding) VALUES (%s, %s, %s)", create_connection)

Use case

Ideally we can do this by Ray 2.7 for LLM application.

@c21 c21 added P1 Issue that should be fixed within a few weeks data Ray Data-related issues Ray 2.7 labels Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Ray Data-related issues P1 Issue that should be fixed within a few weeks Ray 2.7
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants