Created
March 20, 2024 03:16
-
-
Save iAmGhost/a98beca89148c9e5616bf5ba9430295c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import random | |
from azure.cosmos import CosmosClient | |
from azure.cosmos import ThroughputProperties, PartitionKey | |
ENDPOINT = "https://INSTANCE_NAME.documents.azure.com:443/" | |
KEY = "KEY" | |
DB_NAME = 'diagpt' | |
client = CosmosClient(ENDPOINT, KEY) | |
db = client.create_database_if_not_exists( | |
id=DB_NAME, | |
offer_throughput=ThroughputProperties(auto_scale_max_throughput=1000), | |
) | |
container = db.create_container_if_not_exists( | |
id='ms_support_test', | |
partition_key=PartitionKey(path='/partition_key'), | |
) | |
print("Inserting items...") | |
for _ in range(1000): | |
container.create_item({ | |
'id': str(uuid.uuid4()), | |
'partition_key': f'{random.randint(1, 100)}', | |
'email': 'hello@world.com', | |
'category_path': 'test1/test1_1', | |
}) | |
""" | |
Query below works fine on Python SDK, But not on Query Documents V5 action from Power Automate Cosmos DB Connector. | |
""" | |
query = f""" | |
SELECT * FROM r | |
WHERE r.category_path IN ( | |
{",".join([f"'test1/test1_{i}'" for i in range(1000)])} | |
) | |
""" | |
with open("query.txt", "w") as f: | |
f.write(query) | |
for item in container.query_items(query, enable_cross_partition_query=True): | |
print(item) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment