Skip to content

Commit

Permalink
Support invalid partToExtract for parse_url (#11661)
Browse files Browse the repository at this point in the history
Signed-off-by: Haoyang Li <[email protected]>
  • Loading branch information
thirtiseven authored Oct 25, 2024
1 parent 910b64d commit e31a710
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integration_tests/src/main/python/url_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@

url_gen = StringGen(url_pattern)

supported_parts = ['PROTOCOL', 'HOST', 'QUERY', 'PATH']
supported_parts = ['PROTOCOL', 'HOST', 'QUERY', 'PATH', 'invalid', 'path']
unsupported_parts = ['REF', 'FILE', 'AUTHORITY', 'USERINFO']

@pytest.mark.parametrize('data_gen', [url_gen, edge_cases_gen], ids=idfn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3379,7 +3379,7 @@ object GpuOverrides extends Logging {
willNotWorkOnGpu("Fail on error is not supported on GPU when parsing urls.")
}

extractStringLit(a.children(1)).map(_.toUpperCase) match {
extractStringLit(a.children(1)) match {
// In Spark, the key in parse_url could act like a regex, but GPU will match the key
// exactly. When key is literal, GPU will check if the key contains regex special and
// fallbcak to CPU if it does, but we are not able to fallback when key is column.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ object GpuParseUrl {

def isSupportedPart(part: String): Boolean = {
part match {
case PROTOCOL | HOST | QUERY | PATH =>
true
case _ =>
case REF | FILE | AUTHORITY | USERINFO =>
false
case _ => // PROTOCOL, HOST, QUERY, PATH and invalid parts are supported
true
}
}
}
Expand Down Expand Up @@ -73,7 +73,7 @@ case class GpuParseUrl(children: Seq[Expression])
throw new UnsupportedOperationException(s"$this is not supported partToExtract=$part. " +
s"Only PROTOCOL, HOST, QUERY and PATH are supported")
case _ =>
throw new IllegalArgumentException(s"Invalid partToExtract: $partToExtract")
return GpuColumnVector.columnVectorFromNull(url.getRowCount.toInt, StringType)
}
}

Expand Down

0 comments on commit e31a710

Please sign in to comment.