feat(parser): Snowflake SAMPLE / TABLESAMPLE (#483)#501
feat(parser): Snowflake SAMPLE / TABLESAMPLE (#483)#501ajitpratap0 wants to merge 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task —— View job Code Review: Snowflake SAMPLE/TABLESAMPLE ImplementationI've completed a comprehensive review of the PR implementing Snowflake SAMPLE/TABLESAMPLE clause parsing. Here's my detailed feedback: Review Checklist
✅ StrengthsCode Quality & Best Practices
Security & Robustness
Performance Considerations
🔧 Areas for Improvement1. Critical Issue: Missing AST ModelingThe implementation consumes SAMPLE/TABLESAMPLE tokens but doesn't store the parsed information in the AST: // Current implementation (select_subquery.go:103-131) only consumes tokens:
if strings.EqualFold(p.currentToken.Token.Value, "SAMPLE") ||
strings.EqualFold(p.currentToken.Token.Value, "TABLESAMPLE") {
p.advance() // Consumes but doesn't store
// ... consumes method and parentheses but loses information
}Recommended Fix: Add a // In ast.go TableReference struct
Sample *SampleClause // Snowflake/ANSI sampling clause
// In parsing logic
if strings.EqualFold(p.currentToken.Token.Value, "SAMPLE") {
sampleClause, err := p.parseSampleClause()
if err != nil {
return tableRef, err
}
tableRef.Sample = sampleClause
}2. Incomplete Parsing Logic
3. Guard Function Location Mismatch
4. Test Coverage GapsThe test file snowflake_sample_test.go:17-32 only tests successful parsing, missing:
📋 Suggested EnhancementsTest Coverage Expansion// Add to snowflake_sample_test.go
func TestSnowflakeSampleErrors(t *testing.T) {
errorCases := []struct{
name string
query string
expectedError string
}{
{"missing_parens", `SELECT * FROM users SAMPLE 10`, "expected ("},
{"invalid_method", `SELECT * FROM users SAMPLE INVALID (10)`, ""},
{"wrong_dialect", `SELECT * FROM users SAMPLE (10)`, ""}, // using default dialect
}
// ... test error cases
}AST CompletenessComplete the parsing by actually using the existing DocumentationAdd examples to CHANGELOG.md showing the new Snowflake SAMPLE syntax support. ⚡ Performance & Memory
🏁 RecommendationConditional Approval - This PR provides a solid foundation for Snowflake SAMPLE support but requires completion:
The current implementation correctly handles token consumption and maintains parser state, but stops short of providing the complete feature. With the AST modeling completed, this will be a solid addition to the Snowflake dialect support. |
Bumps go.opentelemetry.io/otel/sdk and related packages from v1.42.0 to v1.43.0 to remediate CVE-2026-39883 flagged by the Trivy repository scan. This CVE is the root cause of the Trivy / Security Scan Summary failures on PRs #500 and #501.
* fix(deps): upgrade opentelemetry SDK to v1.43.0 (CVE-2026-39883) Bumps go.opentelemetry.io/otel/sdk and related packages from v1.42.0 to v1.43.0 to remediate CVE-2026-39883 flagged by the Trivy repository scan. This CVE is the root cause of the Trivy / Security Scan Summary failures on PRs #500 and #501. * fix(security): add CVE-2026-39883 to trivyignore (resolved by otel v1.43.0 upgrade) --------- Co-authored-by: Ajit Pratap Singh <ajitpratapsingh@Ajits-Mac-mini-2655.local>
b5b4077 to
5836e08
Compare
|
Claude finished @ajitpratap0's task —— View job Code Review: Snowflake SAMPLE/TABLESAMPLE ImplementationI've completed a comprehensive review of the PR implementing Snowflake SAMPLE/TABLESAMPLE clause parsing. Here's my detailed feedback: Review Checklist
✅ StrengthsCode Quality & Best Practices
Security & Robustness
Performance Considerations
🔧 Areas for Improvement1. Critical Issue: Missing AST ModelingThe implementation consumes SAMPLE/TABLESAMPLE tokens but doesn't store the parsed information in the AST: // Current implementation (select_subquery.go:103-131) only consumes tokens:
if strings.EqualFold(p.currentToken.Token.Value, "SAMPLE") ||
strings.EqualFold(p.currentToken.Token.Value, "TABLESAMPLE") {
p.advance() // Consumes but doesn't store
// ... consumes method and parentheses but loses information
}Recommended Fix: Add a // In ast.go TableReference struct
Sample *SampleClause // Snowflake/ANSI sampling clause
// In parsing logic
if strings.EqualFold(p.currentToken.Token.Value, "SAMPLE") {
sampleClause, err := p.parseSampleClause()
if err != nil {
return tableRef, err
}
tableRef.Sample = sampleClause
}2. Incomplete Parsing Logic
3. Guard Function Location Mismatch
4. Test Coverage GapsThe test file snowflake_sample_test.go:17-32 only tests successful parsing, missing:
📋 Suggested EnhancementsTest Coverage Expansion// Add to snowflake_sample_test.go
func TestSnowflakeSampleErrors(t *testing.T) {
errorCases := []struct{
name string
query string
expectedError string
}{
{"missing_parens", `SELECT * FROM users SAMPLE 10`, "expected ("},
{"invalid_method", `SELECT * FROM users SAMPLE INVALID (10)`, ""},
{"wrong_dialect", `SELECT * FROM users SAMPLE (10)`, ""}, // using default dialect
}
// ... test error cases
}AST CompletenessComplete the parsing by actually using the existing DocumentationAdd examples to CHANGELOG.md showing the new Snowflake SAMPLE syntax support. ⚡ Performance & Memory
🏁 RecommendationConditional Approval - This PR provides a solid foundation for Snowflake SAMPLE support but requires completion:
The current implementation correctly handles token consumption and maintains parser state, but stops short of providing the complete feature. With the AST modeling completed, this will be a solid addition to the Snowflake dialect support. |
|
Claude finished @ajitpratap0's task —— View job Code Review: Snowflake SAMPLE/TABLESAMPLE ImplementationI've completed a comprehensive review of the PR implementing Snowflake SAMPLE/TABLESAMPLE clause parsing. Here's my detailed feedback: Review Checklist
✅ StrengthsCode Quality & Best Practices
Security & Robustness
Performance Considerations
🔧 Areas for Improvement1. Critical Issue: Missing AST ModelingThe implementation consumes SAMPLE/TABLESAMPLE tokens but doesn't store the parsed information in the AST: // Current implementation (select_subquery.go:103-131) only consumes tokens:
if strings.EqualFold(p.currentToken.Token.Value, "SAMPLE") ||
strings.EqualFold(p.currentToken.Token.Value, "TABLESAMPLE") {
p.advance() // Consumes but doesn't store
// ... consumes method and parentheses but loses information
}Recommended Fix: Add a // In ast.go TableReference struct
Sample *SampleClause // Snowflake/ANSI sampling clause
// In parsing logic
if strings.EqualFold(p.currentToken.Token.Value, "SAMPLE") {
sampleClause, err := p.parseSampleClause()
if err != nil {
return tableRef, err
}
tableRef.Sample = sampleClause
}2. Incomplete Parsing Logic
3. Guard Function Location Mismatch
4. Test Coverage GapsThe test file snowflake_sample_test.go:17-32 only tests successful parsing, missing:
📋 Suggested EnhancementsTest Coverage Expansion// Add to snowflake_sample_test.go
func TestSnowflakeSampleErrors(t *testing.T) {
errorCases := []struct{
name string
query string
expectedError string
}{
{"missing_parens", `SELECT * FROM users SAMPLE 10`, "expected ("},
{"invalid_method", `SELECT * FROM users SAMPLE INVALID (10)`, ""},
{"wrong_dialect", `SELECT * FROM users SAMPLE (10)`, ""}, // using default dialect
}
// ... test error cases
}AST CompletenessComplete the parsing by actually using the existing DocumentationAdd examples to CHANGELOG.md showing the new Snowflake SAMPLE syntax support. ⚡ Performance & Memory
🏁 RecommendationConditional Approval - This PR provides a solid foundation for Snowflake SAMPLE support but requires completion:
The current implementation correctly handles token consumption and maintains parser state, but stops short of providing the complete feature. With the AST modeling completed, this will be a solid addition to the Snowflake dialect support. |
Summary
Snowflake `SAMPLE`/`TABLESAMPLE` clause on table references. 6 test shapes, race-tested green. Part of #483.
🤖 Generated with Claude Code