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/transform_paradigm.py
Normal file
116
markitect/query_paradigms/paradigms/transform_paradigm.py
Normal file
@@ -0,0 +1,116 @@
|
||||
"""
|
||||
Data Transformation Paradigm - JSON/YAML/XML serialization.
|
||||
"""
|
||||
|
||||
import time
|
||||
from typing import Dict, Any, List, Optional
|
||||
|
||||
from ..base import BaseQueryParadigm, QueryResult
|
||||
|
||||
|
||||
class DataTransformationParadigm(BaseQueryParadigm):
|
||||
"""Data transformation paradigm for format conversion and serialization."""
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "Data Transformation"
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Serialize and transform data between JSON, YAML, XML, and other formats for application use"
|
||||
|
||||
@property
|
||||
def category(self) -> str:
|
||||
return "procedural"
|
||||
|
||||
@property
|
||||
def complexity(self) -> str:
|
||||
return "intermediate"
|
||||
|
||||
def execute(self, query: str, config: Dict[str, Any] = None) -> QueryResult:
|
||||
"""Execute transformation (not yet implemented)."""
|
||||
start_time = time.time()
|
||||
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": "Data transformation enables format conversion and serialization"
|
||||
},
|
||||
success=False,
|
||||
error_message="Data Transformation paradigm not yet implemented."
|
||||
)
|
||||
|
||||
def get_examples(self) -> List[Dict[str, str]]:
|
||||
"""Get example transformations."""
|
||||
return [
|
||||
{
|
||||
"name": "Export to JSON",
|
||||
"description": "Transform file metadata to JSON",
|
||||
"query": "transform --input=files --output=json --format=compact"
|
||||
},
|
||||
{
|
||||
"name": "Convert to YAML",
|
||||
"description": "Export configuration as YAML",
|
||||
"query": "transform --input=config --output=yaml --pretty"
|
||||
},
|
||||
{
|
||||
"name": "Generate XML",
|
||||
"description": "Create XML from file structure",
|
||||
"query": "transform --input=files --output=xml --schema=file-manifest"
|
||||
},
|
||||
{
|
||||
"name": "Custom template",
|
||||
"description": "Apply custom transformation template",
|
||||
"query": "transform --template=custom.jinja2 --input=files --output=html"
|
||||
}
|
||||
]
|
||||
|
||||
def validate_query(self, query: str) -> tuple[bool, Optional[str]]:
|
||||
"""Validate transformation command."""
|
||||
if not query.strip():
|
||||
return False, "Transformation command cannot be empty"
|
||||
|
||||
if not query.startswith('transform'):
|
||||
return False, "Command must start with 'transform'"
|
||||
|
||||
return True, None
|
||||
|
||||
def get_syntax_help(self) -> str:
|
||||
"""Get syntax help for transformations."""
|
||||
return """Data Transformation Syntax:
|
||||
|
||||
Basic Format:
|
||||
transform --input=<source> --output=<format> [options]
|
||||
|
||||
Input Sources:
|
||||
--input=files - File metadata
|
||||
--input=tags - Tag information
|
||||
--input=config - Configuration data
|
||||
--input=stats - Statistics data
|
||||
|
||||
Output Formats:
|
||||
--output=json - JSON format
|
||||
--output=yaml - YAML format
|
||||
--output=xml - XML format
|
||||
--output=csv - CSV format
|
||||
--output=html - HTML format
|
||||
|
||||
Options:
|
||||
--pretty - Pretty-print output
|
||||
--compact - Compact output
|
||||
--template=<file> - Custom template
|
||||
--schema=<name> - Use predefined schema
|
||||
--filter=<expression> - Filter data
|
||||
|
||||
Examples:
|
||||
transform --input=files --output=json --pretty
|
||||
transform --input=tags --output=yaml --filter="count > 5"
|
||||
transform --template=report.html --input=stats --output=html
|
||||
"""
|
||||
Reference in New Issue
Block a user