You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5.3 KiB
5.3 KiB
SeaweedFS Enhanced SQL CLI Features
🚀 ENHANCED CLI EXPERIENCE IMPLEMENTED!
✅ NEW EXECUTION MODES
Interactive Mode (Enhanced)
weed sql --interactive
# or
weed sql # defaults to interactive if no other options
Features:
- 🎯 Database context switching:
USE database_name;
- 🔄 Output format switching:
\format table|json|csv
- 📝 Command history (basic implementation)
- 🌟 Enhanced prompts with current database context
- ✨ Improved help with advanced WHERE operator examples
Single Query Mode
weed sql --query "SHOW DATABASES" --output json
weed sql --database analytics --query "SELECT COUNT(*) FROM metrics"
Batch File Processing
weed sql --file queries.sql --output csv
weed sql --file batch_queries.sql --output json
✅ MULTIPLE OUTPUT FORMATS
Table Format (ASCII)
weed sql --query "SHOW DATABASES" --output table
+-----------+
| Database |
+-----------+
| analytics |
| user_data |
+-----------+
JSON Format
weed sql --query "SHOW DATABASES" --output json
{
"columns": ["Database"],
"count": 2,
"rows": [
{"Database": "analytics"},
{"Database": "user_data"}
]
}
CSV Format
weed sql --query "SHOW DATABASES" --output csv
Database
analytics
user_data
✅ SMART FORMAT AUTO-DETECTION
- Interactive mode: Defaults to
table
format for readability - Non-interactive mode: Defaults to
json
format for programmatic use - Override with
--output
flag: Always respected
✅ DATABASE CONTEXT SWITCHING
Command Line Context
weed sql --database analytics --interactive
# Starts with analytics database pre-selected
Interactive Context Switching
seaweedfs> USE analytics;
Database changed to: analytics
seaweedfs:analytics> SHOW TABLES;
-- Shows tables in analytics database
✅ COMPREHENSIVE HELP SYSTEM
Enhanced Help Command
seaweedfs> help;
Shows:
- 📊 Metadata Operations: SHOW, DESCRIBE commands
- 🔍 Advanced Querying: Full WHERE clause support
- 📝 DDL Operations: CREATE, DROP TABLE
- ⚙️ Special Commands: USE, \format, help, exit
- 🎯 Extended WHERE Operators: All supported operators with examples
- 💡 Real Examples: Practical query demonstrations
✅ ADVANCED WHERE CLAUSE SUPPORT
All implemented and working in CLI:
-- Comparison operators
SELECT * FROM events WHERE user_id <= 100;
SELECT * FROM events WHERE timestamp >= '2023-01-01';
-- Not equal operators
SELECT * FROM events WHERE status != 'deleted';
SELECT * FROM events WHERE status <> 'inactive';
-- Pattern matching
SELECT * FROM events WHERE username LIKE 'admin%';
SELECT * FROM events WHERE email LIKE '%@company.com';
-- Multi-value matching
SELECT * FROM events WHERE status IN ('active', 'pending', 'verified');
SELECT * FROM events WHERE user_id IN (1, 5, 10, 25);
-- Complex combinations
SELECT * FROM events
WHERE user_id >= 10
AND status != 'deleted'
AND username LIKE 'test%'
AND user_type IN ('premium', 'enterprise');
🛠️ COMMAND LINE INTERFACE
Complete Flag Reference
weed sql [flags]
FLAGS:
-server string SeaweedFS server address (default "localhost:8888")
-interactive Start interactive shell mode
-file string Execute SQL queries from file
-output string Output format: table, json, csv (auto-detected if not specified)
-database string Default database context
-query string Execute single SQL query
-help Show help message
Usage Examples
# Interactive shell
weed sql --interactive
weed sql --database analytics --interactive
# Single query execution
weed sql --query "SHOW DATABASES" --output json
weed sql --query "SELECT * FROM user_events WHERE user_id <= 100" --output table
# Batch processing
weed sql --file queries.sql --output csv
weed sql --file analytics_queries.sql --output json
# Context switching
weed sql --database analytics --query "SHOW TABLES"
weed sql --server broker1:8888 --interactive
📊 PRODUCTION READY FEATURES
✅ Error Handling
- JSON Error Format: Structured error responses for programmatic use
- User-Friendly Errors: Clear error messages for interactive use
- Query Validation: Comprehensive SQL parsing error reporting
✅ Performance Features
- Execution Timing: Query performance metrics in table mode
- Streaming Results: Efficient handling of large result sets
- Timeout Protection: 30-second query timeout with graceful handling
✅ Integration Features
- Real MQ Discovery: Dynamic namespace and topic discovery
- Hybrid Data Scanning: Live logs + archived Parquet files
- Schema-Aware Parsing: Intelligent message interpretation
- Zero Fallback Data: Pure real MQ data discovery
🎯 DEMONSTRATION
Run the complete demo:
./enhanced_cli_demo.sh
Demo covers:
- Single query mode with all output formats
- Batch file processing
- Database context switching
- Advanced WHERE operators (LIKE, IN, <=, >=, !=)
- Real data scanning from hybrid sources
All enhanced CLI features are production-ready and fully tested! 🚀