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 implemented
Syntax 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 arr
AST 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
Problem
ClickHouse's
SAMPLEclause (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.Syntax to Support
AST Changes
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