feat: implement comprehensive query paradigm zoo system (issue #62)
- Created extensible BaseQueryParadigm interface with standardized QueryResult format - Implemented QueryParadigmRegistry for paradigm discovery and management - Added 5 working paradigms: SQL, FTS, GraphQL, JSONPath, Natural Language - Documented 9 additional paradigms: QBE, Batch Manipulation, Visual Query Builder, REST API, NoSQL, UNIX Pipeline, XPath/XQuery, RAG, Data Transformation - Integrated full CLI interface: list, search, show, exec, categories commands - Added comprehensive test suite with 23 test cases covering all components - Auto-registration system enables easy addition of new paradigms - Organized paradigms by category (structural, textual, semantic, visual, procedural, network) and complexity (beginner, intermediate, advanced) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
116
markitect/query_paradigms/paradigms/qbe_paradigm.py
Normal file
116
markitect/query_paradigms/paradigms/qbe_paradigm.py
Normal file
@@ -0,0 +1,116 @@
|
||||
"""
|
||||
Query By Example (QBE) Paradigm - Visual template-based querying.
|
||||
"""
|
||||
|
||||
import time
|
||||
from typing import Dict, Any, List, Optional
|
||||
|
||||
from ..base import BaseQueryParadigm, QueryResult
|
||||
|
||||
|
||||
class QueryByExampleParadigm(BaseQueryParadigm):
|
||||
"""Query By Example paradigm for visual template-based data filtering."""
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "Query By Example"
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Visual template-based queries where users fill in example values to define search criteria"
|
||||
|
||||
@property
|
||||
def category(self) -> str:
|
||||
return "visual"
|
||||
|
||||
@property
|
||||
def complexity(self) -> str:
|
||||
return "beginner"
|
||||
|
||||
def execute(self, query: str, config: Dict[str, Any] = None) -> QueryResult:
|
||||
"""Execute QBE query (not yet implemented)."""
|
||||
start_time = time.time()
|
||||
|
||||
# This is a documentation paradigm - not yet implemented
|
||||
execution_time = (time.time() - start_time) * 1000
|
||||
|
||||
return QueryResult(
|
||||
paradigm=self.name,
|
||||
query=query,
|
||||
execution_time_ms=execution_time,
|
||||
result_count=0,
|
||||
results=[],
|
||||
metadata={
|
||||
"status": "not_implemented",
|
||||
"implementation_issue": "TBD - to be created",
|
||||
"description": "QBE provides a visual interface where users create templates with example values to define search criteria"
|
||||
},
|
||||
success=False,
|
||||
error_message="Query By Example paradigm not yet implemented. This paradigm will provide visual templates for filtering data."
|
||||
)
|
||||
|
||||
def get_examples(self) -> List[Dict[str, str]]:
|
||||
"""Get example QBE templates."""
|
||||
return [
|
||||
{
|
||||
"name": "Filter by author",
|
||||
"description": "Template to find files by specific author",
|
||||
"query": "{'author': 'John Smith', 'type': '*.md'}"
|
||||
},
|
||||
{
|
||||
"name": "Date range filter",
|
||||
"description": "Template to find files within date range",
|
||||
"query": "{'created_after': '2024-01-01', 'created_before': '2024-12-31'}"
|
||||
},
|
||||
{
|
||||
"name": "Tag-based filter",
|
||||
"description": "Template to find files with specific tags",
|
||||
"query": "{'tags': ['documentation', 'api'], 'status': 'published'}"
|
||||
},
|
||||
{
|
||||
"name": "Content pattern",
|
||||
"description": "Template to find files matching content patterns",
|
||||
"query": "{'content_contains': 'function', 'file_extension': '.py'}"
|
||||
}
|
||||
]
|
||||
|
||||
def validate_query(self, query: str) -> tuple[bool, Optional[str]]:
|
||||
"""Validate QBE template structure."""
|
||||
try:
|
||||
import json
|
||||
template = json.loads(query)
|
||||
if not isinstance(template, dict):
|
||||
return False, "QBE template must be a JSON object"
|
||||
return True, None
|
||||
except json.JSONDecodeError:
|
||||
return False, "QBE template must be valid JSON"
|
||||
|
||||
def get_syntax_help(self) -> str:
|
||||
"""Get syntax help for QBE."""
|
||||
return """Query By Example (QBE) Syntax:
|
||||
|
||||
QBE uses JSON templates where you specify example values for the fields you want to filter by:
|
||||
|
||||
Structure:
|
||||
{
|
||||
"field_name": "example_value",
|
||||
"another_field": "another_value"
|
||||
}
|
||||
|
||||
Supported Fields:
|
||||
- author: Author name
|
||||
- type: File type/extension
|
||||
- tags: Array of tags
|
||||
- created_after/created_before: Date filters
|
||||
- content_contains: Text that should appear in content
|
||||
- file_extension: Specific file extensions
|
||||
|
||||
Example:
|
||||
{
|
||||
"author": "Alice Johnson",
|
||||
"tags": ["tutorial", "beginner"],
|
||||
"created_after": "2024-01-01"
|
||||
}
|
||||
|
||||
This template finds files by Alice Johnson with tutorial and beginner tags created after Jan 1, 2024.
|
||||
"""
|
||||
Reference in New Issue
Block a user