-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
Problem
ClickHouse's SAMPLE clause (for approximate query processing on large datasets) is marked as TODO in the test suite and not implemented. This is the last significant gap in ClickHouse dialect support added in v1.13.0.
// clickhouse_test.go:88
// TODO: SAMPLE clause parsing not yet implementedSyntax to Support
-- Sample by ratio
SELECT count() FROM hits SAMPLE 0.1
-- Sample absolute rows
SELECT count() FROM hits SAMPLE 10000
-- Sample with offset
SELECT count() FROM hits SAMPLE 1/3 OFFSET 2/3
-- ARRAY JOIN with SAMPLE
SELECT col FROM table SAMPLE 0.5 ARRAY JOIN arrAST Changes
type SampleClause struct {
Ratio *LiteralValue // 0.1 or 1/3 form
Offset *LiteralValue // OFFSET form (optional)
IsRows bool // SAMPLE 10000 ROWS form
}
// Add to SelectStatement (ClickHouse dialect only)
type SelectStatement struct {
// ...existing fields...
Sample *SampleClause // ClickHouse SAMPLE clause
}Acceptance Criteria
-
SAMPLE ratioparsed (float literal: 0.1, 0.5) -
SAMPLE n/dparsed (fraction form: 1/3, 2/3) -
SAMPLE n ROWSparsed (absolute row count) -
SAMPLE ratio OFFSET offsetparsed - Only active in ClickHouse dialect mode
- Formatter renders SAMPLE clause correctly
- Remove TODO comment from clickhouse_test.go
- 15+ test cases covering all SAMPLE forms
- docs/SQL_COMPATIBILITY.md ClickHouse section updated
Reactions are currently unavailable