diff --git a/api/core/rag/datasource/vdb/clickzetta/README.md b/api/core/rag/datasource/vdb/clickzetta/README.md index 7c8ec85a27..40229f8d44 100644 --- a/api/core/rag/datasource/vdb/clickzetta/README.md +++ b/api/core/rag/datasource/vdb/clickzetta/README.md @@ -187,4 +187,4 @@ Clickzetta supports advanced full-text search with multiple analyzers: - [Clickzetta Vector Search Documentation](../../../../../../../yunqidoc/cn_markdown_20250526/vector-search.md) - [Clickzetta Inverted Index Documentation](../../../../../../../yunqidoc/cn_markdown_20250526/inverted-index.md) -- [Clickzetta SQL Functions](../../../../../../../yunqidoc/cn_markdown_20250526/sql_functions/) \ No newline at end of file +- [Clickzetta SQL Functions](../../../../../../../yunqidoc/cn_markdown_20250526/sql_functions/) diff --git a/api/tests/integration_tests/vdb/clickzetta/README.md b/api/tests/integration_tests/vdb/clickzetta/README.md index a6a95ffeac..c16dca8018 100644 --- a/api/tests/integration_tests/vdb/clickzetta/README.md +++ b/api/tests/integration_tests/vdb/clickzetta/README.md @@ -22,4 +22,4 @@ pytest api/tests/integration_tests/vdb/clickzetta/ ## Security Note -Never commit credentials to the repository. Always use environment variables or secure credential management systems. \ No newline at end of file +Never commit credentials to the repository. Always use environment variables or secure credential management systems. diff --git a/api/tests/integration_tests/vdb/clickzetta/test_clickzetta.py b/api/tests/integration_tests/vdb/clickzetta/test_clickzetta.py index 1ca95c4f72..0aa92bc84a 100644 --- a/api/tests/integration_tests/vdb/clickzetta/test_clickzetta.py +++ b/api/tests/integration_tests/vdb/clickzetta/test_clickzetta.py @@ -150,7 +150,7 @@ class TestClickzettaVector(AbstractVectorTest): batch_size = 25 documents = [] embeddings = [] - + for i in range(batch_size): doc = Document( page_content=f"Batch document {i}: This is a test document for batch processing.", @@ -182,7 +182,7 @@ class TestClickzettaVector(AbstractVectorTest): metadata={"doc_id": "special_doc", "test": "edge_case"} ) embeddings = [[0.1, 0.2, 0.3, 0.4]] - + vector_store.add_texts(documents=[special_doc], embeddings=embeddings) assert vector_store.text_exists("special_doc") @@ -215,9 +215,9 @@ class TestClickzettaVector(AbstractVectorTest): metadata={"doc_id": "en_doc_2", "lang": "english"} ), ] - + embeddings = [[0.1, 0.2, 0.3, 0.4] for _ in documents] - + vector_store.create(texts=documents, embeddings=embeddings) # Test Chinese full-text search diff --git a/api/tests/integration_tests/vdb/clickzetta/test_docker_integration.py b/api/tests/integration_tests/vdb/clickzetta/test_docker_integration.py index b8a83d63c0..5f2e290ad4 100644 --- a/api/tests/integration_tests/vdb/clickzetta/test_docker_integration.py +++ b/api/tests/integration_tests/vdb/clickzetta/test_docker_integration.py @@ -22,18 +22,18 @@ def test_clickzetta_connection(): vcluster=os.getenv("CLICKZETTA_VCLUSTER", "default"), database=os.getenv("CLICKZETTA_SCHEMA", "dify") ) - + with conn.cursor() as cursor: # Test basic connectivity cursor.execute("SELECT 1 as test") result = cursor.fetchone() print(f"✓ Connection test: {result}") - + # Check if our test table exists cursor.execute("SHOW TABLES IN dify") tables = cursor.fetchall() print(f"✓ Existing tables: {[t[1] for t in tables if t[0] == 'dify']}") - + # Check if test collection exists test_collection = "collection_test_dataset" if test_collection in [t[1] for t in tables if t[0] == 'dify']: @@ -42,14 +42,14 @@ def test_clickzetta_connection(): print(f"✓ Table structure for {test_collection}:") for col in columns: print(f" - {col[0]}: {col[1]}") - + # Check for indexes cursor.execute(f"SHOW INDEXES IN dify.{test_collection}") indexes = cursor.fetchall() print(f"✓ Indexes on {test_collection}:") for idx in indexes: print(f" - {idx}") - + return True except Exception as e: print(f"✗ Connection test failed: {e}") @@ -59,7 +59,7 @@ def test_dify_api(): """Test Dify API with Clickzetta backend""" print("\n=== Testing Dify API ===") base_url = "http://localhost:5001" - + # Wait for API to be ready max_retries = 30 for i in range(max_retries): @@ -73,7 +73,7 @@ def test_dify_api(): print("✗ Dify API is not responding") return False time.sleep(2) - + # Check vector store configuration try: # This is a simplified check - in production, you'd use proper auth @@ -86,47 +86,47 @@ def test_dify_api(): def verify_table_structure(): """Verify the table structure meets Dify requirements""" print("\n=== Verifying Table Structure ===") - + expected_columns = { "id": "VARCHAR", "page_content": "VARCHAR", "metadata": "VARCHAR", # JSON stored as VARCHAR in Clickzetta "vector": "ARRAY" } - + expected_metadata_fields = [ "doc_id", "doc_hash", "document_id", "dataset_id" ] - + print("✓ Expected table structure:") for col, dtype in expected_columns.items(): print(f" - {col}: {dtype}") - + print("\n✓ Required metadata fields:") for field in expected_metadata_fields: print(f" - {field}") - + print("\n✓ Index requirements:") print(" - Vector index (HNSW) on 'vector' column") print(" - Full-text index on 'page_content' (optional)") print(" - Functional index on metadata->>'$.doc_id' (recommended)") print(" - Functional index on metadata->>'$.document_id' (recommended)") - + return True def main(): """Run all tests""" print("Starting Clickzetta integration tests for Dify Docker\n") - + tests = [ ("Direct Clickzetta Connection", test_clickzetta_connection), ("Dify API Status", test_dify_api), ("Table Structure Verification", verify_table_structure), ] - + results = [] for test_name, test_func in tests: try: @@ -135,21 +135,21 @@ def main(): except Exception as e: print(f"\n✗ {test_name} crashed: {e}") results.append((test_name, False)) - + # Summary print("\n" + "="*50) print("Test Summary:") print("="*50) - + passed = sum(1 for _, success in results if success) total = len(results) - + for test_name, success in results: status = "✅ PASSED" if success else "❌ FAILED" print(f"{test_name}: {status}") - + print(f"\nTotal: {passed}/{total} tests passed") - + if passed == total: print("\n🎉 All tests passed! Clickzetta is ready for Dify Docker deployment.") print("\nNext steps:")