Skip to content

Commit

Permalink
feat(snowflake): add userinfo URL parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and jcrist committed Aug 7, 2024
1 parent dc6bfe2 commit 524a2fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ibis/backends/sql/compilers/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ def visit_ExtractFragment(self, op, *, arg):
self.f.as_varchar(self.f.get(self.f.parse_url(arg, 1), "fragment")), ""
)

def visit_ExtractUserInfo(self, op, *, arg):
host = self.f.get(self.f.parse_url(arg), "host")
return self.if_(
host.like(sge.convert("%@%")), self.f.split_part(host, "@", 1), NULL
)

def visit_Unnest(self, op, *, arg):
sep = sge.convert(util.guid())
split = self.f.split(
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def test_substr_with_null_values(backend, alltypes, df):
"user:pass",
marks=[
pytest.mark.notyet(
["bigquery", "clickhouse", "snowflake", "trino"],
["bigquery", "clickhouse", "trino"],
raises=com.OperationNotDefinedError,
reason="doesn't support `USERINFO`",
)
Expand Down

0 comments on commit 524a2fa

Please sign in to comment.