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

Support insert data into specified partition name #5

Open
xige-16 opened this issue Mar 7, 2024 · 2 comments
Open

Support insert data into specified partition name #5

xige-16 opened this issue Mar 7, 2024 · 2 comments

Comments

@xige-16
Copy link
Contributor

xige-16 commented Mar 7, 2024

The current import parameters are only the collection name, and the partition name cannot be specified.

from pyspark.sql import SparkSession

columns = ["id", "text", "vec"]
data = [(1, "a", [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0]),
    (2, "b", [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0]),
    (3, "c", [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0]),
    (4, "d", [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0])]
sample_df = spark.sparkContext.parallelize(data).toDF(columns)
sample_df.write \
    .mode("append") \
    .option("milvus.host", "localhost") \
    .option("milvus.port", "19530") \
    .option("milvus.collection.name", "hello_spark_milvus") \
    .option("milvus.collection.vectorField", "vec") \
    .option("milvus.collection.vectorDim", "8") \
    .option("milvus.collection.primaryKeyField", "id") \
    .format("milvus") \
    .save()

@xiaofan-luan
Copy link

@xige-16 glad you are back!

@xige-16
Copy link
Contributor Author

xige-16 commented Mar 20, 2024

A better way is to specify the database parameter in create partition. Now it relies on the database variable in the connection and waits for the Java SDK to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants