Skip to content

Commit 0197f96

Browse files
committed
Add support for dotted paths in JSON type parameters and unwrap SKIP
Two changes for JSON/OBJECT type parsing and explain output: 1. Parser: Parse dotted paths (like a.b.c) for JSON type parameter names Previously only single identifiers were captured as parameter names. 2. Explain: Unwrap SKIP function calls in ObjectTypeArgument ClickHouse shows just the path/pattern, not the SKIP wrapper. Fixes 18 statements across 8 test files: - 03205_json_syntax (12 statements) - 03227_json_invalid_regexp (2 statements) - 03620_json_advanced_shared_data_seek_bug (1 statement) - Plus metadata updates for other JSON-related tests
1 parent 4ceaa25 commit 0197f96

File tree

10 files changed

+34
-47
lines changed

10 files changed

+34
-47
lines changed

internal/explain/statements.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,15 @@ func explainDataType(sb *strings.Builder, n *ast.DataType, indent string, depth
10141014

10151015
func explainObjectTypeArgument(sb *strings.Builder, n *ast.ObjectTypeArgument, indent string, depth int) {
10161016
fmt.Fprintf(sb, "%sASTObjectTypeArgument (children %d)\n", indent, 1)
1017+
// SKIP function calls are unwrapped - only the path/pattern is shown
1018+
if fn, ok := n.Expr.(*ast.FunctionCall); ok {
1019+
if strings.ToUpper(fn.Name) == "SKIP" || strings.ToUpper(fn.Name) == "SKIP REGEXP" {
1020+
if len(fn.Arguments) > 0 {
1021+
Node(sb, fn.Arguments[0], depth+1)
1022+
return
1023+
}
1024+
}
1025+
}
10171026
Node(sb, n.Expr, depth+1)
10181027
}
10191028

parser/parser.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3689,11 +3689,27 @@ func (p *Parser) parseDataType() *ast.DataType {
36893689
}
36903690
}
36913691

3692+
36923693
if isNamedParam {
36933694
// Parse as name + type pair
3695+
// For JSON/OBJECT types, the name can be a dotted path like a.b.c
36943696
pos := p.current.Pos
3695-
paramName := p.current.Value
3697+
var nameParts []string
3698+
nameParts = append(nameParts, p.current.Value)
36963699
p.nextToken()
3700+
// Parse additional dotted parts if this is a JSON/OBJECT type
3701+
if isObjectType {
3702+
for p.currentIs(token.DOT) {
3703+
p.nextToken() // consume dot
3704+
if p.currentIs(token.IDENT) || p.current.Token.IsKeyword() {
3705+
nameParts = append(nameParts, p.current.Value)
3706+
p.nextToken()
3707+
} else {
3708+
break
3709+
}
3710+
}
3711+
}
3712+
paramName := strings.Join(nameParts, ".")
36973713
// Parse the type for this parameter
36983714
paramType := p.parseDataType()
36993715
if paramType != nil {
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt15": true,
4-
"stmt17": true,
5-
"stmt19": true,
6-
"stmt21": true,
7-
"stmt23": true,
8-
"stmt25": true,
9-
"stmt27": true,
10-
"stmt29": true,
11-
"stmt31": true,
12-
"stmt33": true,
13-
"stmt35": true,
14-
"stmt37": true
15-
}
16-
}
1+
{}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"explain_todo": {
3-
"stmt14": true,
4-
"stmt6": true
3+
"stmt14": true
54
}
65
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"explain_todo": {
3-
"stmt14": true,
4-
"stmt6": true
3+
"stmt14": true
54
}
65
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt5": true
4-
}
5-
}
1+
{}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt2": true,
4-
"stmt3": true
5-
}
6-
}
1+
{}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt5": true
4-
}
5-
}
1+
{}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt5": true
4-
}
5-
}
1+
{}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt3": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)