Skip to content

Commit 3619ee7

Browse files
committed
Add range function
1 parent a0a57a8 commit 3619ee7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

datajunction-server/datajunction_server/sql/functions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4780,6 +4780,25 @@ def infer_type(
47804780
return [arg.key, arg.value]
47814781

47824782

4783+
class Range(TableFunction):
4784+
"""
4785+
range(start[, end[, step[, numSlices]]]) / range(end)
4786+
Returns a table with a single BIGINT column `id` containing values
4787+
within the specified range.
4788+
"""
4789+
4790+
dialects = [Dialect.SPARK]
4791+
4792+
4793+
@Range.register
4794+
def infer_type(
4795+
*args: ct.IntegerBase,
4796+
) -> List[ct.NestedField]:
4797+
from datajunction_server.sql.parsing.ast import Name
4798+
4799+
return [ct.NestedField(name=Name("id"), field_type=ct.BigIntType())]
4800+
4801+
47834802
class FunctionRegistryDict(dict):
47844803
"""
47854804
Custom dictionary mapping for functions

0 commit comments

Comments
 (0)