Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ Available test flags:

## Updating skipped_tests_by_size.txt

After enabling tests, regenerate the file:
After enabling tests, regenerate the file. The script only includes tests that:
- Have `"skip": true` in metadata.json
- Do NOT have `"invalid_syntax"` in metadata.json (these can't be implemented)
- Have an `ast.json` file (tests without it are unparseable)

```bash
cd parser/testdata
for dir in */; do
if [ -f "$dir/metadata.json" ] && grep -q '"skip": true' "$dir/metadata.json" 2>/dev/null; then
if [ -f "$dir/query.sql" ]; then
size=$(wc -c < "$dir/query.sql")
name="${dir%/}"
echo "$size $name"
ls -d */ | while read dir; do
dir="${dir%/}"
if [ -f "$dir/metadata.json" ] && [ -f "$dir/ast.json" ] && [ -f "$dir/query.sql" ]; then
if grep -q '"skip": true' "$dir/metadata.json" 2>/dev/null; then
if grep -qv '"invalid_syntax"' "$dir/metadata.json" 2>/dev/null; then
size=$(wc -c < "$dir/query.sql")
echo "$size $dir"
fi
fi
fi
done | sort -n > ../../skipped_tests_by_size.txt
Expand Down
85 changes: 85 additions & 0 deletions parser/parse_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,60 @@ func (p *Parser) parseColumnReferenceOrFunctionCall() (ast.ScalarExpression, err
p.nextToken() // consume dot
}

// Check for :: (user-defined type method call): a.b::func()
if p.curTok.Type == TokenColonColon && len(identifiers) > 0 {
p.nextToken() // consume ::

// Parse function name
if p.curTok.Type != TokenIdent {
return nil, fmt.Errorf("expected function name after ::, got %s", p.curTok.Literal)
}
funcName := &ast.Identifier{Value: p.curTok.Literal, QuoteType: "NotQuoted"}
p.nextToken()

// Expect (
if p.curTok.Type != TokenLParen {
return nil, fmt.Errorf("expected ( after function name, got %s", p.curTok.Literal)
}
p.nextToken() // consume (

// Build SchemaObjectName from identifiers
schemaObjName := identifiersToSchemaObjectName(identifiers)

fc := &ast.FunctionCall{
CallTarget: &ast.UserDefinedTypeCallTarget{
SchemaObjectName: schemaObjName,
},
FunctionName: funcName,
UniqueRowFilter: "NotSpecified",
WithArrayWrapper: false,
}

// Parse parameters
if p.curTok.Type != TokenRParen {
for {
param, err := p.parseScalarExpression()
if err != nil {
return nil, err
}
fc.Parameters = append(fc.Parameters, param)

if p.curTok.Type != TokenComma {
break
}
p.nextToken() // consume comma
}
}

// Expect )
if p.curTok.Type != TokenRParen {
return nil, fmt.Errorf("expected ) in function call, got %s", p.curTok.Literal)
}
p.nextToken()

return fc, nil
}

// If followed by ( it's a function call
if p.curTok.Type == TokenLParen {
return p.parseFunctionCallFromIdentifiers(identifiers)
Expand Down Expand Up @@ -1953,5 +2007,36 @@ func (p *Parser) parseBooleanPrimaryExpression() (ast.BooleanExpression, error)
}, nil
}

// identifiersToSchemaObjectName converts a slice of identifiers to a SchemaObjectName.
// For 1 identifier: BaseIdentifier
// For 2 identifiers: SchemaIdentifier.BaseIdentifier
// For 3 identifiers: DatabaseIdentifier.SchemaIdentifier.BaseIdentifier
// For 4 identifiers: ServerIdentifier.DatabaseIdentifier.SchemaIdentifier.BaseIdentifier
func identifiersToSchemaObjectName(identifiers []*ast.Identifier) *ast.SchemaObjectName {
son := &ast.SchemaObjectName{
Count: len(identifiers),
Identifiers: identifiers,
}

switch len(identifiers) {
case 1:
son.BaseIdentifier = identifiers[0]
case 2:
son.SchemaIdentifier = identifiers[0]
son.BaseIdentifier = identifiers[1]
case 3:
son.DatabaseIdentifier = identifiers[0]
son.SchemaIdentifier = identifiers[1]
son.BaseIdentifier = identifiers[2]
case 4:
son.ServerIdentifier = identifiers[0]
son.DatabaseIdentifier = identifiers[1]
son.SchemaIdentifier = identifiers[2]
son.BaseIdentifier = identifiers[3]
}

return son
}

// ======================= New Statement Parsing Functions =======================

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"skip": true}
{"skip": false}
2 changes: 1 addition & 1 deletion parser/testdata/SetVariableStatementTests90/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"skip": true}
{"skip": false}
Loading
Loading