Skip to content

Commit

Permalink
feat(snowflake): implement RegexSplit
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and gforsyth committed Dec 19, 2023
1 parent cfe0329 commit 2c1a726
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
message="You have an incompatible version of 'pyarrow' installed",
category=UserWarning,
)
from snowflake.sqlalchemy import ARRAY, DOUBLE, OBJECT, URL
from snowflake.sqlalchemy import ARRAY, DOUBLE, OBJECT, URL, VARCHAR

from ibis.backends.snowflake.converter import SnowflakePandasData
from ibis.backends.snowflake.datatypes import SnowflakeType
Expand Down Expand Up @@ -113,6 +113,11 @@ class SnowflakeCompiler(AlchemyCompiler):
"returns": ARRAY,
"source": """return Array(count).fill(value).flat();""",
},
"ibis_udfs.public.regexp_split": {
"inputs": {"value": VARCHAR, "pattern": VARCHAR},
"returns": ARRAY,
"source": """return value.split(new RegExp(pattern, "g"));""",
},
}


Expand Down
1 change: 1 addition & 0 deletions ibis/backends/snowflake/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ def _timestamp_range(t, op):
3,
),
ops.TimestampRange: _timestamp_range,
ops.RegexSplit: fixed_arity(sa.func.ibis_udfs.public.regexp_split, 2),
}
)

Expand Down

0 comments on commit 2c1a726

Please sign in to comment.