Skip to content

Commit 2fce208

Browse files
committed
ref: refactor extension_registry better exception handling, naming and added function type
1 parent 799b8a9 commit 2fce208

File tree

12 files changed

+792
-501
lines changed

12 files changed

+792
-501
lines changed

src/substrait/builders/type.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ def precision_timestamp_tz(precision: int, nullable=True) -> stt.Type:
223223
)
224224

225225

226+
def timestamp(nullable=True) -> stt.Type:
227+
return stt.Type(
228+
timestamp=stt.Type.Timestamp(
229+
nullability=stt.Type.NULLABILITY_NULLABLE
230+
if nullable
231+
else stt.Type.NULLABILITY_REQUIRED,
232+
)
233+
)
234+
235+
226236
def struct(types: Iterable[stt.Type], nullable=True) -> stt.Type:
227237
return stt.Type(
228238
struct=stt.Type.Struct(

src/substrait/dataframe/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def col(name: str) -> Expression:
1111
"""Column selection."""
1212
return Expression(column(name))
1313

14+
1415
# TODO handle str_as_lit argument
1516
def parse_into_expr(expr, str_as_lit: bool):
1617
return expr._to_compliant_expr(substrait.dataframe)

src/substrait/dataframe/dataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def select(
2929
expressions = [e.expr for e in exprs] + [
3030
expr.alias(alias).expr for alias, expr in named_exprs.items()
3131
]
32-
return DataFrame(select(self.plan, expressions=expressions))
32+
return DataFrame(select(self.plan, expressions=expressions))
3333

3434
# TODO handle version
3535
def _with_version(self, version):

src/substrait/dataframe/expression.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
UnboundExtendedExpression,
33
ExtendedExpressionOrUnbound,
44
resolve_expression,
5-
scalar_function
5+
scalar_function,
66
)
77
import substrait.gen.proto.type_pb2 as stp
88
import substrait.gen.proto.extended_expression_pb2 as stee
@@ -30,7 +30,9 @@ def __init__(self, expr: UnboundExtendedExpression):
3030
def alias(self, alias: str):
3131
self.expr = _alias(self.expr, alias)
3232
return self
33-
33+
3434
def abs(self):
35-
self.expr = scalar_function("functions_arithmetic.yaml", "abs", expressions=[self.expr])
35+
self.expr = scalar_function(
36+
"functions_arithmetic.yaml", "abs", expressions=[self.expr]
37+
)
3638
return self

0 commit comments

Comments
 (0)