Skip to content

Commit

Permalink
[SPARK-50031][SQL][FOLLOW-UP] Add tests for try_parse_url in the co…
Browse files Browse the repository at this point in the history
…nnect module

### What changes were proposed in this pull request?
Add tests in `PlanGenerationTestSuite` for `try_parse_url` function introduced in [this](#48500) PR and generate the corresponding golden files.

### Why are the changes needed?
The added tests ensure the new function behaves as expected.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Tests added.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #48637 from jovanm-db/goldenFiles.

Authored-by: Jovan Markovic <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
  • Loading branch information
jovanm-db authored and MaxGekk committed Oct 25, 2024
1 parent 6e82d59 commit c558d4d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,14 @@ class PlanGenerationTestSuite
fn.parse_url(fn.col("g"), fn.col("g"), fn.col("g"))
}

functionTest("try_parse_url") {
fn.try_parse_url(fn.col("g"), fn.col("g"))
}

functionTest("try_parse_url with key") {
fn.try_parse_url(fn.col("g"), fn.col("g"), fn.col("g"))
}

functionTest("printf") {
fn.printf(fn.col("g"), fn.col("a"), fn.col("g"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Project [parse_url(g#0, g#0, false) AS try_parse_url(g, g)#0]
+- LocalRelation <empty>, [id#0L, a#0, b#0, d#0, e#0, f#0, g#0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Project [parse_url(g#0, g#0, g#0, false) AS try_parse_url(g, g, g)#0]
+- LocalRelation <empty>, [id#0L, a#0, b#0, d#0, e#0, f#0, g#0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"common": {
"planId": "1"
},
"project": {
"input": {
"common": {
"planId": "0"
},
"localRelation": {
"schema": "struct\u003cid:bigint,a:int,b:double,d:struct\u003cid:bigint,a:int,b:double\u003e,e:array\u003cint\u003e,f:map\u003cstring,struct\u003cid:bigint,a:int,b:double\u003e\u003e,g:string\u003e"
}
},
"expressions": [{
"unresolvedFunction": {
"functionName": "try_parse_url",
"arguments": [{
"unresolvedAttribute": {
"unparsedIdentifier": "g"
}
}, {
"unresolvedAttribute": {
"unparsedIdentifier": "g"
}
}]
}
}]
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"common": {
"planId": "1"
},
"project": {
"input": {
"common": {
"planId": "0"
},
"localRelation": {
"schema": "struct\u003cid:bigint,a:int,b:double,d:struct\u003cid:bigint,a:int,b:double\u003e,e:array\u003cint\u003e,f:map\u003cstring,struct\u003cid:bigint,a:int,b:double\u003e\u003e,g:string\u003e"
}
},
"expressions": [{
"unresolvedFunction": {
"functionName": "try_parse_url",
"arguments": [{
"unresolvedAttribute": {
"unparsedIdentifier": "g"
}
}, {
"unresolvedAttribute": {
"unparsedIdentifier": "g"
}
}, {
"unresolvedAttribute": {
"unparsedIdentifier": "g"
}
}]
}
}]
}
}
Binary file not shown.

0 comments on commit c558d4d

Please sign in to comment.