|
@ -152,7 +152,7 @@ func (e *SQLEngine) executeSelectStatement(ctx context.Context, stmt *sqlparser. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Create HybridMessageScanner for the topic (reads both live logs + Parquet files)
|
|
|
// Create HybridMessageScanner for the topic (reads both live logs + Parquet files)
|
|
|
// ✅ RESOLVED TODO: Get real filerClient from broker connection
|
|
|
|
|
|
|
|
|
// RESOLVED TODO: Get real filerClient from broker connection
|
|
|
var filerClient filer_pb.FilerClient |
|
|
var filerClient filer_pb.FilerClient |
|
|
if e.catalog.brokerClient != nil { |
|
|
if e.catalog.brokerClient != nil { |
|
|
var filerClientErr error |
|
|
var filerClientErr error |
|
@ -235,7 +235,7 @@ func (e *SQLEngine) executeSelectStatement(ctx context.Context, stmt *sqlparser. |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Build hybrid scan options
|
|
|
// Build hybrid scan options
|
|
|
// ✅ RESOLVED TODO: Extract from WHERE clause time filters
|
|
|
|
|
|
|
|
|
// RESOLVED TODO: Extract from WHERE clause time filters
|
|
|
startTimeNs, stopTimeNs := int64(0), int64(0) |
|
|
startTimeNs, stopTimeNs := int64(0), int64(0) |
|
|
if stmt.Where != nil { |
|
|
if stmt.Where != nil { |
|
|
startTimeNs, stopTimeNs = e.extractTimeFilters(stmt.Where.Expr) |
|
|
startTimeNs, stopTimeNs = e.extractTimeFilters(stmt.Where.Expr) |
|
@ -1097,18 +1097,18 @@ func (e *SQLEngine) executeAggregationQuery(ctx context.Context, hybridScanner * |
|
|
startTimeNs, stopTimeNs = e.extractTimeFilters(stmt.Where.Expr) |
|
|
startTimeNs, stopTimeNs = e.extractTimeFilters(stmt.Where.Expr) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 🚀 FAST PATH: Try to use parquet statistics for optimization
|
|
|
|
|
|
|
|
|
// FAST PATH: Try to use parquet statistics for optimization
|
|
|
// This can be ~130x faster than scanning all data
|
|
|
// This can be ~130x faster than scanning all data
|
|
|
if stmt.Where == nil { // Only optimize when no complex WHERE clause
|
|
|
if stmt.Where == nil { // Only optimize when no complex WHERE clause
|
|
|
fastResult, canOptimize := e.tryFastParquetAggregation(ctx, hybridScanner, aggregations) |
|
|
fastResult, canOptimize := e.tryFastParquetAggregation(ctx, hybridScanner, aggregations) |
|
|
if canOptimize { |
|
|
if canOptimize { |
|
|
fmt.Printf("✅ Using fast parquet statistics for aggregation (skipped full scan)\n") |
|
|
|
|
|
|
|
|
fmt.Printf("Using fast parquet statistics for aggregation (skipped full scan)\n") |
|
|
return fastResult, nil |
|
|
return fastResult, nil |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// SLOW PATH: Fall back to full table scan
|
|
|
// SLOW PATH: Fall back to full table scan
|
|
|
fmt.Printf("⚠️ Using full table scan for aggregation (parquet optimization not applicable)\n") |
|
|
|
|
|
|
|
|
fmt.Printf("Using full table scan for aggregation (parquet optimization not applicable)\n") |
|
|
|
|
|
|
|
|
// Build scan options for full table scan (aggregations need all data)
|
|
|
// Build scan options for full table scan (aggregations need all data)
|
|
|
hybridScanOptions := HybridScanOptions{ |
|
|
hybridScanOptions := HybridScanOptions{ |
|
|